zabbix_export:
  version: '7.4'
  template_groups:
    - uuid: 748ad4d098d447d492bb935c907f652f
      name: Templates/Databases
  templates:
    - uuid: 001a1677f6a949b6bddfdb2926023300
      template: 'MSSQL by ODBC'
      name: 'MSSQL by ODBC'
      description: |
        This template is designed for the effortless deployment of MSSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
        
        Setup:
        
        1. Create an MSSQL user for monitoring.
        
          View Server State and View Any Definition permissions should be granted to the user.
          Grant this user read permissions to the sysjobschedules, sysjobhistory, and sysjobs tables.
        
          For more information, see MSSQL documentation:
          
          - Create a database user: https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/create-a-database-user?view=sql-server-ver16
          
          - GRANT Server Permissions: https://docs.microsoft.com/en-us/sql/t-sql/statements/grant-server-permissions-transact-sql?view=sql-server-ver16
          
          - Configure a User to Create and Manage SQL Server Agent Jobs: https://docs.microsoft.com/en-us/sql/ssms/agent/configure-a-user-to-create-and-manage-sql-server-agent-jobs?view=sql-server-ver16
        
        2. Set the user name and password in the host macros ({$MSSQL.USER} and {$MSSQL.PASSWORD}).
        
        3. Do not forget to install Microsoft ODBC driver on Zabbix server or Zabbix proxy and specify data source name in macro {$MSSQL.DSN}.
          
          See Microsoft documentation for instructions: https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16.
        
          Note! Credentials in the odbc.ini do not work for MSSQL.
        
        The "Service's TCP port state" item uses the {$MSSQL.HOST} and {$MSSQL.PORT} macros to check the availability of the MSSQL instance, change these if necessary. Keep in mind that if dynamic ports are used on the MSSQL server side, this check will not work correctly.
        
        If your instance uses a non-default TCP port, set the port in your section of odbc.ini in the line Server = IP or FQDN name, port.
        
        Note: You can use the context macros {$MSSQL.BACKUP_FULL.USED}, {$MSSQL.BACKUP_LOG.USED}, and {$MSSQL.BACKUP_DIFF.USED} to disable backup age triggers for a certain database. If set to a value other than "1", the trigger expression for the backup age will not fire.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        1. Create an MSSQL user for monitoring. For example, "zbx_monitor".
        
        **View Server State** and **View Any Definition** permissions should be granted to the user.
        Grant this user read permissions to the `sysjobschedules`, `sysjobhistory`, and `sysjobs` tables.
        
        For example, using T-SQL commands:
        
        ```sql
        GRANT SELECT ON OBJECT::msdb.dbo.sysjobs TO zbx_monitor;
        GRANT SELECT ON OBJECT::msdb.dbo.sysjobservers TO zbx_monitor;
        GRANT SELECT ON OBJECT::msdb.dbo.sysjobactivity TO zbx_monitor;
        GRANT EXECUTE ON OBJECT::msdb.dbo.agent_datetime TO zbx_monitor;
        ```
        
        For more information, see MSSQL documentation:
        
        [Create a database user](https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/create-a-database-user?view=sql-server-ver16)
        
        [GRANT Server Permissions](https://docs.microsoft.com/en-us/sql/t-sql/statements/grant-server-permissions-transact-sql?view=sql-server-ver16)
        
        [Configure a User to Create and Manage SQL Server Agent Jobs](https://docs.microsoft.com/en-us/sql/ssms/agent/configure-a-user-to-create-and-manage-sql-server-agent-jobs?view=sql-server-ver16)
        
        2. Set the username and password in the `MSSQL user` and `MSSQL password` host wizard configuration fields.
        
        3. Do not forget to install Microsoft ODBC driver on Zabbix server or Zabbix proxy and specify data source name in the `MSSQL DSN` host wizard configuration field.
        
        See Microsoft documentation for instructions: https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16.
        
        **Note! Credentials in the `odbc.ini` do not work for MSSQL.**
        
        The `Service's TCP port state` item uses the `MSSQL address` and `MSSQL TCP port` host wizard configuration fields to check the availability of the MSSQL instance, change these if necessary. Keep in mind that if dynamic ports are used on the MSSQL server side, this check will not work correctly.
        
        If your instance uses a non-default TCP port, set the port in your section of `odbc.ini` in the line Server = IP or FQDN name, port.
        
        Note: You can use the `Monitoring of full backup`, `Monitoring of log backup`, and `Monitoring of differential backup` host wizard configuration fields to disable backup age triggers. If set to unselected state, the trigger expression for the backup age will not fire.
      vendor:
        name: Zabbix
        version: 7.4-3
      groups:
        - name: Templates/Databases
      items:
        - uuid: f495898e37c94bfda4ce387f7129b996
          name: 'Get availability groups'
          type: ODBC
          key: 'db.odbc.get[get_availability_group,"{$MSSQL.DSN}"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT
              ag.name as group_name,
              ISNULL(ags.primary_recovery_health, 2) as primary_recovery_health,
              ISNULL(ags.primary_replica, 'Unknown') as primary_replica,
              ISNULL(
                ags.secondary_recovery_health, 2
              ) as secondary_recovery_health,
              ags.synchronization_health as synchronization_health
            FROM
              sys.dm_hadr_availability_group_states ags
            JOIN sys.availability_groups ag ON ag.group_id = ags.group_id
          username: '{$MSSQL.USER}'
          password: '{$MSSQL.PASSWORD}'
          description: 'The item gets availability group states - name, primary and secondary health, synchronization health.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 9c902b33ed254e1892e44218a67876d3
          name: 'Get database'
          type: ODBC
          key: 'db.odbc.get[get_database,"{$MSSQL.DSN}"]'
          delay: 1h
          history: '0'
          value_type: TEXT
          params: |
            SELECT name as dbname, recovery_model
            FROM sys.databases
          username: '{$MSSQL.USER}'
          password: '{$MSSQL.PASSWORD}'
          description: 'Getting databases - database name and recovery model.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 9948ac27a2f84ba5a74ee0860d934f4e
          name: 'Get DB mirroring'
          type: ODBC
          key: 'db.odbc.get[get_db_mirroring,"{$MSSQL.DSN}"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT
              ISNULL(m.mirroring_role, 0) as mirroring_role,
              ISNULL(m.mirroring_role_sequence, 0) as mirroring_role_sequence,
              ISNULL(m.mirroring_state, 7) as mirroring_state,
              ISNULL(m.mirroring_witness_state, 3) as mirroring_witness_state,
              ISNULL(m.mirroring_safety_level, 3) as mirroring_safety_level,
              db_name(m.database_id) as dbname
            FROM
              sys.database_mirroring as m
            WHERE
              m.mirroring_state_desc IS NOT NULL
          username: '{$MSSQL.USER}'
          password: '{$MSSQL.PASSWORD}'
          description: 'Getting DB mirroring.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: cae1f9b034b04357b038212b04cac794
          name: 'Get job status'
          type: ODBC
          key: 'db.odbc.get[get_job_status,"{$MSSQL.DSN}"]'
          delay: 10m
          history: '0'
          value_type: TEXT
          params: |
            SELECT sj.name AS job_name,
              sj.enabled AS enabled,
              sjs.last_run_outcome AS run_status,
              sjs.last_outcome_message AS last_run_status_message,
              sjs.last_run_duration/10000*3600 + sjs.last_run_duration/100%100*60 + sjs.last_run_duration%100 AS run_duration,
              CASE sjs.last_run_date
                WHEN 0 THEN NULL
                ELSE CONVERT(
                  VARCHAR(25),
                  TODATETIMEOFFSET(msdb.dbo.agent_datetime(sjs.last_run_date,sjs.last_run_time), DATEPART(TZoffset, SYSDATETIMEOFFSET())),
                  126)
              END AS last_run_date_time,
              sja.next_scheduled_run_date AS next_run_date_time
            FROM msdb..sysjobs AS sj
            LEFT JOIN msdb..sysjobservers AS sjs
              ON sj.job_id = sjs.job_id
            LEFT JOIN (
              SELECT job.job_id,
                max(act.session_id) AS s_id,
                CONVERT(
                  VARCHAR(25),
                  TODATETIMEOFFSET(max(act.next_scheduled_run_date), DATEPART(TZoffset, SYSDATETIMEOFFSET())),
                  126) AS next_scheduled_run_date
              FROM msdb..sysjobs AS job
              LEFT JOIN msdb..sysjobactivity AS act
                ON act.job_id = job.job_id
              GROUP BY  job.job_id ) AS sja
                ON sja.job_id = sj.job_id
            WHERE Enabled = 1
          username: '{$MSSQL.USER}'
          password: '{$MSSQL.PASSWORD}'
          description: 'The item gets the SQL agent job status.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 9b106ca122fb4b75a761e80f4239f906
          name: 'Get last backup'
          type: ODBC
          key: 'db.odbc.get[get_last_backup,"{$MSSQL.DSN}"]'
          delay: 10m
          history: '0'
          value_type: TEXT
          params: |
            SELECT bs.database_name as dbname,
              [type], 
              DATEDIFF(SECOND, bs.backup_finish_date, getdate()) as time_since_last_backup, 
              (DATEDIFF(SECOND, bs.backup_start_date, bs.backup_finish_date)) as duration,
              db.recovery_model as db_recovery_model
            FROM msdb.dbo.backupset as bs
            LEFT JOIN sys.databases as db ON bs.database_name = db.name
            WHERE bs.database_name not in (
              SELECT AGDatabases.database_name AS Databasename
              FROM sys.dm_hadr_availability_group_states States
              INNER JOIN master.sys.availability_groups Groups 
                ON States.group_id = Groups.group_id
              INNER JOIN sys.availability_databases_cluster AGDatabases 
                ON Groups.group_id = AGDatabases.group_id
              WHERE primary_replica != @@Servername OR primary_replica is NULL
            ) and db.name is not NULL
            GROUP BY bs.database_name, 
              backup_finish_date, 
              [type], 
              backup_start_date,
              db.recovery_model
            HAVING backup_finish_date = (
              SELECT MAX(backup_finish_date)
              FROM msdb.dbo.backupset 
              WHERE database_name = bs.database_name 
                AND bs.type = [type]
            )
            ORDER BY bs.database_name
          username: '{$MSSQL.USER}'
          password: '{$MSSQL.PASSWORD}'
          description: 'The item gets information about backup processes.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 3960ea4dc0054ee099d5bca005535e6b
          name: 'Get local DB'
          type: ODBC
          key: 'db.odbc.get[get_local_db,"{$MSSQL.DSN}"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT ag.name AS group_name, 
              drs.database_state as database_state, 
              drs.is_suspended as is_suspended, 
              drs.synchronization_health as synchronization_health, 
              arcs.replica_server_name AS replica_name,
              db_name(drs.database_id) AS dbname, 
              drs.is_local
            FROM sys.dm_hadr_database_replica_states drs 
            JOIN sys.dm_hadr_availability_replica_cluster_states arcs
              ON arcs.replica_id = drs.replica_id
            JOIN sys.availability_groups ag 
              ON ag.group_id = arcs.group_id
            JOIN sys.dm_hadr_availability_replica_states ars 
              ON ars.replica_id = arcs.replica_id
            WHERE drs.is_local = 1
          username: '{$MSSQL.USER}'
          password: '{$MSSQL.PASSWORD}'
          description: 'Getting the states of the local availability database.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: e4480bba876d472294920020734eadf5
          name: 'Get non-local DB'
          type: ODBC
          key: 'db.odbc.get[get_non_local_db,"{$MSSQL.DSN}"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT ag.name AS group_name, 
              ISNULL(drs.log_send_queue_size, 0) as log_send_queue_size, 
              ISNULL(drs.redo_queue_size, 0) as redo_queue_size, 
              arcs.replica_server_name AS replica_name,
              db_name(drs.database_id) AS dbname, 
              drs.is_local
            FROM sys.dm_hadr_database_replica_states drs 
            JOIN sys.dm_hadr_availability_replica_cluster_states arcs
              ON arcs.replica_id = drs.replica_id
            JOIN sys.availability_groups ag 
              ON ag.group_id = arcs.group_id
            JOIN sys.dm_hadr_availability_replica_states ars 
              ON ars.replica_id = arcs.replica_id
            WHERE drs.is_local = 0
          username: '{$MSSQL.USER}'
          password: '{$MSSQL.PASSWORD}'
          description: 'Getting the non-local availability database.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 3fcb3b84bdee42428bedc39fcc582c9e
          name: 'Get quorum'
          type: ODBC
          key: 'db.odbc.get[get_quorum,"{$MSSQL.DSN}"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT quorum_type, quorum_state, cluster_name
            FROM sys.dm_hadr_cluster
          username: '{$MSSQL.USER}'
          password: '{$MSSQL.PASSWORD}'
          description: 'Getting quorum - cluster name, type, and state.'
          timeout: 10s
          tags:
            - tag: component
              value: raw
        - uuid: 69a31cdfbf9b4099bf89adb26e8b9f06
          name: 'Get quorum member'
          type: ODBC
          key: 'db.odbc.get[get_quorum_member,"{$MSSQL.DSN}"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT a.member_name, a.member_type, a.member_state, a.number_of_quorum_votes, b.cluster_name
            FROM sys.dm_hadr_cluster_members a
            CROSS JOIN sys.dm_hadr_cluster b
          username: '{$MSSQL.USER}'
          password: '{$MSSQL.PASSWORD}'
          description: 'Getting quorum members - member name, type, state, and number of quorum votes.'
          timeout: 10s
          tags:
            - tag: component
              value: raw
        - uuid: 7a82483c605d4e8eb67c2576069cf8a9
          name: 'Get replica'
          type: ODBC
          key: 'db.odbc.get[get_replica,"{$MSSQL.DSN}"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT 
              ars.connected_state as connected_state, 
              ars.is_local as is_local, 
              arcs.join_state as join_state, 
              ISNULL(ars.operational_state, 6) as operational_state, 
              ISNULL(ars.recovery_health, 2) as recovery_health, 
              ars.role as role, 
              ars.synchronization_health as synchronization_health, 
              ag.name as group_name, 
              arcs.replica_server_name as replica_name 
            FROM 
              sys.dm_hadr_availability_replica_cluster_states as arcs 
            JOIN sys.availability_groups ag ON ag.group_id = arcs.group_id 
            JOIN sys.dm_hadr_availability_replica_states ars ON ars.replica_id = arcs.replica_id
          username: '{$MSSQL.USER}'
          password: '{$MSSQL.PASSWORD}'
          description: 'Getting the database replica.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: ff07b83d161c4e0fbddf8c2e2c282258
          name: 'Get performance counters'
          type: ODBC
          key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          delay: 0;m0-59
          history: '0'
          value_type: TEXT
          params: |
            DECLARE @SQLNAME NVARCHAR(22)
            SET @SQLNAME = CASE WHEN @@SERVICENAME = 'MSSQLSERVER' THEN 'SQLServer' ELSE 'MSSQL$' + @@SERVICENAME END
            SELECT object_name,
              counter_name,
              instance_name,
              cntr_value
            FROM sys.dm_os_performance_counters
            UNION SELECT @SQLNAME AS object_name,
              'Version' AS counter_name,
              @@version AS instance_name,
              0 AS cntr_value
            UNION SELECT @SQLNAME AS object_name,
              'Uptime' AS counter_name,
              '' AS instance_name,
              DATEDIFF(second, sqlserver_start_time, GETDATE()) AS cntr_value
            FROM sys.dm_os_sys_info
            UNION SELECT @SQLNAME + ':Databases' AS object_name,
              'State' AS counter_name,
              name AS instance_name,
              state AS cntr_value
            FROM sys.databases
            UNION SELECT a.object_name,
              'BufferCacheHitRatio' AS counter_name,
              '' AS instance_name,
              cast(a.cntr_value * ISNULL((100.0 / NULLIF(b.cntr_value,0)),0) AS dec(3, 0)) AS cntr_value
            FROM sys.dm_os_performance_counters a
            JOIN (
              SELECT cntr_value,
                OBJECT_NAME
              FROM sys.dm_os_performance_counters
              WHERE counter_name = 'Buffer cache hit ratio base'
                AND OBJECT_NAME = @SQLNAME + ':Buffer Manager'
            ) b
              ON a.OBJECT_NAME = b.OBJECT_NAME
            WHERE a.counter_name = 'Buffer cache hit ratio'
              AND a.OBJECT_NAME = @SQLNAME + ':Buffer Manager'
            UNION SELECT a.object_name,
              'WorktablesFromCacheRatio' AS counter_name,
              '' AS instance_name,
              cast(a.cntr_value * ISNULL((100.0 / NULLIF(b.cntr_value,0)),0) AS dec(3, 0)) AS cntr_value
            FROM sys.dm_os_performance_counters a
            JOIN (
              SELECT cntr_value,
                OBJECT_NAME
              FROM sys.dm_os_performance_counters
              WHERE counter_name = 'Worktables From Cache Base'
                AND OBJECT_NAME = @SQLNAME + ':Access Methods'
            ) b
              ON a.OBJECT_NAME = b.OBJECT_NAME
            WHERE a.counter_name = 'Worktables From Cache Ratio'
              AND a.OBJECT_NAME = @SQLNAME + ':Access Methods'
            UNION SELECT a.object_name,
              'CacheHitRatio' AS counter_name,
              '_Total' AS instance_name,
              cast(a.cntr_value * ISNULL((100.0 / NULLIF(b.cntr_value,0)),0) AS dec(3, 0)) AS cntr_value
            FROM sys.dm_os_performance_counters a
            JOIN (
              SELECT cntr_value,
                OBJECT_NAME
              FROM sys.dm_os_performance_counters
              WHERE counter_name = 'Cache Hit Ratio base'
                AND OBJECT_NAME = @SQLNAME + ':Plan Cache'
                AND instance_name = '_Total'
            ) b
              ON a.OBJECT_NAME = b.OBJECT_NAME
            WHERE a.counter_name = 'Cache Hit Ratio'
              AND a.OBJECT_NAME = @SQLNAME + ':Plan Cache'
              AND instance_name = '_Total'
          username: '{$MSSQL.USER}'
          password: '{$MSSQL.PASSWORD}'
          description: 'The item gets server global status information.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: c0400032a74549078448a928f17d3128
          name: 'Get Access Methods counters'
          type: DEPENDENT
          key: mssql.access_methods.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets server information about access methods.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Access Methods'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 9a83826b50ac4928b9a716cf94ed6b61
          name: 'Auto-param attempts per second'
          type: DEPENDENT
          key: mssql.autoparam_attempts_sec.rate
          value_type: FLOAT
          description: 'Number of auto-parameterization attempts per second. The total should be the sum of the failed, safe, and unsafe auto-parameterizations. Auto-parameterization occurs when an instance of SQL Server tries to parameterize a Transact-SQL request by replacing some literals with parameters so that reuse of the resulting cached execution plan across multiple similar-looking requests is possible. Note that auto-parameterizations are also known as simple parameterizations in the newer versions of SQL Server. This counter does not include forced parameterizations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Auto-Param Attempts/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: 1d49af2907d541719e4482439de3ef40
          name: 'Average latch wait time'
          type: CALCULATED
          key: mssql.average_latch_wait_time
          delay: 0;m0-59s3
          value_type: FLOAT
          units: ms
          params: |
            (last(//mssql.average_latch_wait_time_raw) - last(//mssql.average_latch_wait_time_raw,#2)) /
            (last(//mssql.average_latch_wait_time_base) - last(//mssql.average_latch_wait_time_base,#2) +
            (last(//mssql.average_latch_wait_time_base) - last(//mssql.average_latch_wait_time_base,#2)=0))
          description: 'Average latch wait time (in milliseconds) for latch requests that had to wait.'
          tags:
            - tag: component
              value: wait-time
        - uuid: f9d78cd9c941471287a24ca94005e9ac
          name: 'Average latch wait time base'
          type: DEPENDENT
          key: mssql.average_latch_wait_time_base
          description: 'For internal use only.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Average Latch Wait Time Base'')].cntr_value.first()'
          master_item:
            key: mssql.latches_info.raw
          tags:
            - tag: component
              value: wait-time
        - uuid: 7248e70669674ef5a7a85deb20b1fe8e
          name: 'Average latch wait time raw'
          type: DEPENDENT
          key: mssql.average_latch_wait_time_raw
          units: ms
          description: 'Average latch wait time (in milliseconds) for latch requests that had to wait.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Average Latch Wait Time (ms)'')].cntr_value.first()'
          master_item:
            key: mssql.latches_info.raw
          tags:
            - tag: component
              value: wait-time
        - uuid: 2915866b5891480aafd73463aca88a21
          name: 'Total average wait time'
          type: CALCULATED
          key: mssql.average_wait_time
          delay: 0;m0-59s3
          value_type: FLOAT
          units: ms
          params: |
            (last(//mssql.average_wait_time_raw) - last(//mssql.average_wait_time_raw,#2)) /
            (last(//mssql.average_wait_time_base) - last(//mssql.average_wait_time_base,#2) +
            (last(//mssql.average_wait_time_base) - last(//mssql.average_wait_time_base,#2)=0))
          description: 'The average wait time, in milliseconds, for each lock request that had to wait.'
          tags:
            - tag: component
              value: wait-time
          triggers:
            - uuid: fad2c1e9d0ba45bcbb47ccbb327f0b98
              expression: 'min(/MSSQL by ODBC/mssql.average_wait_time,5m)>{$MSSQL.AVERAGE_WAIT_TIME.MAX}'
              name: 'MSSQL: Total average wait time for locks is high'
              event_name: 'MSSQL: Total average wait time for locks is high (over {$MSSQL.AVERAGE_WAIT_TIME.MAX}ms for 5m)'
              priority: WARNING
              description: 'An average wait time longer than 500 ms may indicate excessive blocking. This value should generally correlate to "Lock Waits/sec" and move up or down with it accordingly.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 2a63096aa40a4374bdd7426b9fe0767e
          name: 'Total average wait time base'
          type: DEPENDENT
          key: mssql.average_wait_time_base
          description: 'For internal use only.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Average Wait Time Base'')].cntr_value.first()'
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: wait-time
        - uuid: f0cd7858dabf4b7da93314dc9a8ddeaa
          name: 'Total average wait time raw'
          type: DEPENDENT
          key: mssql.average_wait_time_raw
          units: ms
          description: 'Average amount of wait time (in milliseconds) for each lock request that resulted in a wait. Information for all locks.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Average Wait Time (ms)'')].cntr_value.first()'
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: wait-time
        - uuid: 00b6e46811fd43a396e2a38dd976d220
          name: 'Batch requests per second'
          type: DEPENDENT
          key: mssql.batch_requests_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Number of Transact-SQL command batches received per second. This statistic is affected by all constraints (such as I/O, number of users, cache size, complexity of requests, and so on). High batch requests mean good throughput.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Batch Requests/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: ed950d204a1f40a6925856828c7807aa
          name: 'Buffer cache hit ratio'
          type: DEPENDENT
          key: mssql.buffer_cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: 'Indicates the percentage of pages found in the buffer cache without having to read from the disk. The ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses. After a long period of time, the ratio changes very little. Since reading from the cache is much less expensive than reading from the disk, a higher value is preferred for this item. To increase the buffer cache hit ratio, consider increasing the amount of memory available to MSSQL Server or using the buffer pool extension feature.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''BufferCacheHitRatio'')].cntr_value.first()'
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: cache
          triggers:
            - uuid: f84fa297023a4aee903e4d32bbad9360
              expression: 'max(/MSSQL by ODBC/mssql.buffer_cache_hit_ratio,5m)<{$MSSQL.BUFFER_CACHE_RATIO.MIN.CRIT}'
              name: 'MSSQL: Percentage of the buffer cache efficiency is low'
              event_name: 'MSSQL: Percentage of the buffer cache efficiency is low (below {$MSSQL.BUFFER_CACHE_RATIO.MIN.CRIT}% for 5m)'
              priority: HIGH
              description: 'Too low buffer cache hit ratio.'
              tags:
                - tag: scope
                  value: performance
            - uuid: 42e5bf05da06425282134d3cf806d023
              expression: 'max(/MSSQL by ODBC/mssql.buffer_cache_hit_ratio,5m)<{$MSSQL.BUFFER_CACHE_RATIO.MIN.WARN}'
              name: 'MSSQL: Percentage of the buffer cache efficiency is low'
              event_name: 'MSSQL: Percentage of the buffer cache efficiency is low (below {$MSSQL.BUFFER_CACHE_RATIO.MIN.WARN}% for 5m)'
              priority: WARNING
              description: 'Low buffer cache hit ratio.'
              dependencies:
                - name: 'MSSQL: Percentage of the buffer cache efficiency is low'
                  expression: 'max(/MSSQL by ODBC/mssql.buffer_cache_hit_ratio,5m)<{$MSSQL.BUFFER_CACHE_RATIO.MIN.CRIT}'
              tags:
                - tag: scope
                  value: performance
        - uuid: eadb0b4b4eed412c9a29137a2f4232fd
          name: 'Get Buffer Manager counters'
          type: DEPENDENT
          key: mssql.buffer_manager.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets server information about the buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Buffer Manager'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 1900fc83a4d74c599f5f3438450b5d8b
          name: 'Cache hit ratio'
          type: DEPENDENT
          key: mssql.cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: 'Ratio between cache hits and lookups.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''CacheHitRatio'')].cntr_value.first()'
          master_item:
            key: mssql.cache_info.raw
          tags:
            - tag: component
              value: cache
        - uuid: b9bab8e37b9c46acbf9c64073bfcf0e6
          name: 'Get Cache counters'
          type: DEPENDENT
          key: mssql.cache_info.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets server information about cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Plan Cache'' && @.instance_name==''_Total'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 064e1279ae0a4260ab02c08cd3c3f77d
          name: 'Cache objects in use'
          type: DEPENDENT
          key: mssql.cache_objects_in_use
          description: 'Number of cache objects in use.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Cache Objects in use'')].cntr_value.first()'
          master_item:
            key: mssql.cache_info.raw
          tags:
            - tag: component
              value: cache
        - uuid: de8c0d7f9c0b42438560dc28e47fdd19
          name: 'Cache object counts'
          type: DEPENDENT
          key: mssql.cache_object_counts
          description: 'Number of cache objects in the cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Cache Object Counts'')].cntr_value.first()'
          master_item:
            key: mssql.cache_info.raw
          tags:
            - tag: component
              value: cache
        - uuid: ae2d22cd04ed452dbdb04ae3f71b8586
          name: 'Cache pages'
          type: DEPENDENT
          key: mssql.cache_pages
          description: 'Number of 8-kilobyte (KB) pages used by cache objects.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Cache Pages'')].cntr_value.first()'
          master_item:
            key: mssql.cache_info.raw
          tags:
            - tag: component
              value: cache
            - tag: component
              value: page
        - uuid: d72b6aadab0c4d6d83bc72da0ce661c3
          name: 'Checkpoint pages per second'
          type: DEPENDENT
          key: mssql.checkpoint_pages_sec.rate
          value_type: FLOAT
          description: 'Indicates the number of pages flushed to the disk per second by a checkpoint or other operation which required all dirty pages to be flushed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Checkpoint pages/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
            - tag: component
              value: performance
        - uuid: 9c1ca822375644669821fe1bea4c5f2a
          name: 'Database pages'
          type: DEPENDENT
          key: mssql.database_pages
          description: 'Indicates the number of pages in the buffer pool with database content.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Database pages'')].cntr_value.first()'
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
        - uuid: 871e3520aac84c18bcaf2f3a0d565b79
          name: 'Total data file size'
          type: DEPENDENT
          key: mssql.data_files_size
          units: B
          description: 'Total size of all data files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Data File(s) Size (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: mssql.db_info.raw
          tags:
            - tag: component
              value: application
        - uuid: 9f7bc0b3ae25483cb7290ef6feaa5c84
          name: 'Get DB counters'
          type: DEPENDENT
          key: mssql.db_info.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets summary information about databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Databases'' && @.instance_name==''_Total'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 4cdecc74a6e44b57b17f44988d3ffa21
          name: 'Total errors per second'
          type: DEPENDENT
          key: mssql.errors_sec.rate
          value_type: FLOAT
          description: 'Number of errors per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Errors/sec'' && @.instance_name==''_Total'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_errors.raw
          tags:
            - tag: component
              value: error
            - tag: component
              value: performance
        - uuid: 5ed7f6931c42424f8ec3dbe2e6c46f03
          name: 'Failed auto-params per second'
          type: DEPENDENT
          key: mssql.failed_autoparams_sec.rate
          value_type: FLOAT
          description: 'Number of failed auto-parameterization attempts per second. This number should be small. Note that auto-parameterizations are also known as simple parameterizations in the newer versions of SQL Server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Failed Auto-Params/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: cee8f4d47d41463299c50b5c7925a650
          name: 'Forwarded records per second'
          type: DEPENDENT
          key: mssql.forwarded_records_sec.rate
          value_type: FLOAT
          description: 'Number of records per second fetched through forwarded record pointers.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Forwarded Records/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: performance
        - uuid: 22d1a41352c4477ba3db5d1a9e038597
          name: 'Free list stalls per second'
          type: DEPENDENT
          key: mssql.free_list_stalls_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Indicates the number of requests per second that had to wait for a free page.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Free list stalls/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: performance
          triggers:
            - uuid: f055a294ef3b43dd8958e77c303a5fee
              expression: 'min(/MSSQL by ODBC/mssql.free_list_stalls_sec.rate,5m)>{$MSSQL.FREE_LIST_STALLS.MAX}'
              name: 'MSSQL: Number of rps waiting for a free page is high'
              event_name: 'MSSQL: Number of rps waiting for a free page is high (over {$MSSQL.FREE_LIST_STALLS.MAX} for 5m)'
              priority: WARNING
              description: 'Some requests have to wait for a free page.'
              tags:
                - tag: scope
                  value: performance
        - uuid: ace67686bb93456c80b40be1f33c173f
          name: 'Full scans per second'
          type: DEPENDENT
          key: mssql.full_scans_sec.rate
          value_type: FLOAT
          description: 'Number of unrestricted full scans per second. These can be either base-table or full-index scans. Values greater than 1 or 2 indicate that there are table / index page scans. If that is combined with high CPU, this counter requires further investigation, otherwise, if the full scans are on small tables, it can be ignored.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Full Scans/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: performance
        - uuid: 6c17a38a9e9246ecbad3a6b2cb83c6cc
          name: 'Get General Statistics counters'
          type: DEPENDENT
          key: mssql.general_statistics.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets general statistics information.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*General Statistics'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: raw
        - uuid: f2539791f65a40569bcf6b1c89647904
          name: 'Granted Workspace Memory'
          type: DEPENDENT
          key: mssql.granted_workspace_memory
          units: B
          description: 'Specifies the total amount of memory currently granted to executing processes, such as hash, sort, bulk copy, and index creation operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Granted Workspace Memory (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: 585f1a22108143d8b39337900da8860c
          name: 'Index searches per second'
          type: DEPENDENT
          key: mssql.index_searches_sec.rate
          value_type: FLOAT
          description: 'Number of index searches per second. These are used to start a range scan, reposition a range scan, revalidate a scan point, fetch a single index record, and search down the index to locate where to insert a new row.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Index Searches/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: performance
        - uuid: eafdabca35bd40a58432dd36a210a4e4
          name: 'Errors per second (Info errors)'
          type: DEPENDENT
          key: mssql.info_errors_sec.rate
          value_type: FLOAT
          description: 'Number of errors per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Errors/sec'' && @.instance_name==''Info Errors'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_errors.raw
          tags:
            - tag: component
              value: error
            - tag: component
              value: performance
        - uuid: b68d1f8108d7494b9d4d891911708c72
          name: 'Errors per second (Kill connection errors)'
          type: DEPENDENT
          key: mssql.kill_connection_errors_sec.rate
          value_type: FLOAT
          description: 'Number of errors per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Errors/sec'' && @.instance_name==''Kill Connection Errors'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_errors.raw
          tags:
            - tag: component
              value: error
            - tag: component
              value: performance
        - uuid: 04714203d50645fdb4c69e333facd60e
          name: 'Get Latches counters'
          type: DEPENDENT
          key: mssql.latches_info.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets server information about latches.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Latches'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: raw
        - uuid: c1242c5530654057bca59cb9ad12c319
          name: 'Latch waits per second'
          type: DEPENDENT
          key: mssql.latch_waits_sec.rate
          value_type: FLOAT
          units: rps
          description: 'The number of latch requests that could not be granted immediately. Latches are lightweight means of holding a very transient server resource, such as an address in memory.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Latch Waits/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.latches_info.raw
          tags:
            - tag: component
              value: performance
            - tag: component
              value: wait-time
        - uuid: 66cc84326bd146ac89f91ddeaa61f63a
          name: 'Lazy writes per second'
          type: DEPENDENT
          key: mssql.lazy_writes_sec.rate
          value_type: FLOAT
          description: 'Indicates the number of buffers written per second by the buffer manager''s lazy writer. The lazy writer is a system process that flushes out batches of dirty, aged buffers (buffers that contain changes that must be written back to the disk before the buffer can be reused for a different page) and makes them available to user processes. The lazy writer eliminates the need to perform frequent checkpoints in order to create available buffers.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Lazy writes/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: performance
          triggers:
            - uuid: 8aa547cda82f4dfcaef5ca0467590f64
              expression: 'min(/MSSQL by ODBC/mssql.lazy_writes_sec.rate,5m)>{$MSSQL.LAZY_WRITES.MAX}'
              name: 'MSSQL: Number of buffers written per second by the lazy writer is high'
              event_name: 'MSSQL: Number of buffers written per second by the lazy writer is high (over {$MSSQL.LAZY_WRITES.MAX} for 5m)'
              priority: WARNING
              description: 'The number of buffers written per second by the buffer manager''s lazy writer exceeds the threshold.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 1b39ade916d243299f6350faaee167c8
          name: 'Get Locks counters'
          type: DEPENDENT
          key: mssql.locks_info.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets server information about locks.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Locks'' && @.instance_name==''_Total'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 1b4c71c016504eb08b1a49146095c231
          name: 'Total lock requests per second'
          type: DEPENDENT
          key: mssql.lock_requests_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Number of new locks and lock conversions per second requested from the lock manager.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Lock Requests/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: lock
            - tag: component
              value: performance
          triggers:
            - uuid: be4e0b1aec8d494b984be248424d69cf
              expression: 'min(/MSSQL by ODBC/mssql.lock_requests_sec.rate,5m)>{$MSSQL.LOCK_REQUESTS.MAX}'
              name: 'MSSQL: Total number of locks per second is high'
              event_name: 'MSSQL: Total number of locks per second is high (over {$MSSQL.LOCK_REQUESTS.MAX} for 5m)'
              priority: WARNING
              description: 'Number of new locks and lock conversions per second requested from the lock manager is high.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 0ac1aab7013249c6a0beb89217bf52c6
          name: 'Total lock requests per second that timed out'
          type: DEPENDENT
          key: mssql.lock_timeouts_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Number of timed out lock requests per second, including requests for NOWAIT locks.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Lock Timeouts/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: lock
            - tag: component
              value: performance
          triggers:
            - uuid: 9b62d84b8d9c4209b894151f59c42b27
              expression: 'min(/MSSQL by ODBC/mssql.lock_timeouts_sec.rate,5m)>{$MSSQL.LOCK_TIMEOUTS.MAX}'
              name: 'MSSQL: Total lock requests per second that timed out is high'
              event_name: 'MSSQL: Total lock requests per second that timed out is high (over {$MSSQL.LOCK_TIMEOUTS.MAX} for 5m)'
              priority: WARNING
              description: 'The total number of timed out lock requests per second, including requests for NOWAIT locks, is high.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 77be28b4732d4665a4e880f2ea309245
          name: 'Total lock requests per second that required waiting'
          type: DEPENDENT
          key: mssql.lock_waits_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Number of lock requests per second that required the caller to wait.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Lock Waits/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: lock
            - tag: component
              value: performance
          triggers:
            - uuid: 879748a03c89495398b41fc1dbeba9ed
              expression: 'min(/MSSQL by ODBC/mssql.lock_waits_sec.rate,5m)>0'
              name: 'MSSQL: Some blocking is occurring for 5m'
              priority: AVERAGE
              description: 'Values greater than zero indicate at least some blocking is occurring, while a value of zero can quickly eliminate blocking as a potential root-cause problem.'
              tags:
                - tag: scope
                  value: performance
        - uuid: bf4ef99559f94147b9b64144f6b795c0
          name: 'Lock wait time'
          type: DEPENDENT
          key: mssql.lock_wait_time
          value_type: FLOAT
          units: ms
          description: 'Average of total wait time (in milliseconds) for locks in the last second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Lock Wait Time (ms)'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: lock
        - uuid: c7856bdb5285421cb79cec0782fa1188
          name: 'Logins per second'
          type: DEPENDENT
          key: mssql.logins_sec.rate
          value_type: FLOAT
          description: 'Total number of logins started per second. This does not include pooled connections. Any value over 2 may indicate insufficient connection pooling.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Logins/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.general_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: cf4af2cbeaff42b2a71c91544286998f
          name: 'Logouts per second'
          type: DEPENDENT
          key: mssql.logouts_sec.rate
          value_type: FLOAT
          description: 'Total number of logout operations started per second. Any value over 2 may indicate insufficient connection pooling.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Logouts/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.general_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: e0620ce52e6d4269b9d12e82c749a146
          name: 'Total log file size'
          type: DEPENDENT
          key: mssql.log_files_size
          units: B
          description: 'Total size of all the transaction log files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Log File(s) Size (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: mssql.db_info.raw
          tags:
            - tag: component
              value: log
        - uuid: 636e7c85a79947a39f7b176e8e3c5b82
          name: 'Total log file used size'
          type: DEPENDENT
          key: mssql.log_files_used_size
          units: B
          description: 'The cumulative size of all the log files in the database.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Log File(s) Used Size (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: mssql.db_info.raw
          tags:
            - tag: component
              value: log
        - uuid: 28c1045fb77249aea23f55f48dd89c69
          name: 'Maximum workspace memory'
          type: DEPENDENT
          key: mssql.maximum_workspace_memory
          units: B
          description: 'Indicates the maximum amount of memory available for executing processes, such as hash, sort, bulk copy, and index creation operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Maximum Workspace Memory (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: d39c5f2b89de4bc88c7724a8e2b270d7
          name: 'Memory grants outstanding'
          type: DEPENDENT
          key: mssql.memory_grants_outstanding
          description: 'Specifies the total number of processes that have successfully acquired a workspace memory grant.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Memory Grants Outstanding'')].cntr_value.first()'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: cb468e25c20f43f08fcefd45354ff882
          name: 'Memory grants pending'
          type: DEPENDENT
          key: mssql.memory_grants_pending
          description: 'Specifies the total number of processes waiting for a workspace memory grant.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Memory Grants Pending'')].cntr_value.first()'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: 982b21186af84be2a34f76e5bccb7a27
          name: 'Get Memory counters'
          type: DEPENDENT
          key: mssql.mem_manager.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets memory information.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Memory Manager'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 18c0d77ded2b4533a559643006a93406
          name: 'Total lock requests per second that have deadlocks'
          type: DEPENDENT
          key: mssql.number_deadlocks_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Number of lock requests per second that resulted in a deadlock.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Number of Deadlocks/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: deadlock
            - tag: component
              value: performance
          triggers:
            - uuid: a8f77c32a7194af9b2674f0931c25212
              expression: 'min(/MSSQL by ODBC/mssql.number_deadlocks_sec.rate,5m)>{$MSSQL.DEADLOCKS.MAX}'
              name: 'MSSQL: Number of deadlocks is high'
              event_name: 'MSSQL: Number of deadlocks is high (over {$MSSQL.DEADLOCKS.MAX} for 5m)'
              priority: AVERAGE
              description: 'Too many deadlocks are occurring currently.'
              tags:
                - tag: scope
                  value: performance
        - uuid: bbb7fcac41b2403ab0b0c76f3437e81f
          name: 'Errors per second (DB offline errors)'
          type: DEPENDENT
          key: mssql.offline_errors_sec.rate
          value_type: FLOAT
          description: 'Number of errors per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Errors/sec'' && @.instance_name==''DB Offline Errors'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_errors.raw
          tags:
            - tag: component
              value: error
            - tag: component
              value: performance
        - uuid: 94a869db684046d9b65db9ee022a9c9e
          name: 'Page life expectancy'
          type: DEPENDENT
          key: mssql.page_life_expectancy
          value_type: FLOAT
          units: s
          description: 'Indicates the number of seconds a page will stay in the buffer pool without references.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Page life expectancy'')].cntr_value.first()'
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
          triggers:
            - uuid: 4eb155a86f8b4441a6707e8a3816a068
              expression: 'max(/MSSQL by ODBC/mssql.page_life_expectancy,15m)<{$MSSQL.PAGE_LIFE_EXPECTANCY.MIN}'
              name: 'MSSQL: Page life expectancy is low'
              event_name: 'MSSQL: Page life expectancy is low (less {$MSSQL.PAGE_LIFE_EXPECTANCY.MIN}min for 15m)'
              priority: HIGH
              description: 'The page stays in the buffer pool without references for less time than the threshold value.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 628f787578e04b83882aca052a7f976a
          name: 'Page lookups per second'
          type: DEPENDENT
          key: mssql.page_lookups_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Indicates the number of requests per second to find a page in the buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Page lookups/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: performance
        - uuid: 433257a5dfe4488c8073db03bfb05315
          name: 'Page reads per second'
          type: DEPENDENT
          key: mssql.page_reads_sec.rate
          value_type: FLOAT
          description: 'Indicates the number of physical database page reads that are issued per second. This statistic displays the total number of physical page reads across all databases. As physical I/O is expensive, you may be able to minimize the cost either by using a larger data cache, intelligent indexes, and more efficient queries, or by changing the database design.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Page reads/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
            - tag: component
              value: performance
          triggers:
            - uuid: c0b765b22b264d7c9086edc5cda35592
              expression: 'min(/MSSQL by ODBC/mssql.page_reads_sec.rate,5m)>{$MSSQL.PAGE_READS.MAX}'
              name: 'MSSQL: Number of physical database page reads per second is high'
              event_name: 'MSSQL: Number of physical database page reads per second is high (over {$MSSQL.PAGE_READS.MAX} for 5m)'
              priority: WARNING
              description: 'The physical database page reads are issued too frequently.'
              tags:
                - tag: scope
                  value: performance
        - uuid: fc3dd6a1bf1242769e2b58f25421a19d
          name: 'Page splits per second'
          type: DEPENDENT
          key: mssql.page_splits_sec.rate
          value_type: FLOAT
          description: 'Number of page splits per second that occur as a result of overflowing index pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Page Splits/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: page
            - tag: component
              value: performance
        - uuid: a8b3639fe7b44d88a75e724c083518b5
          name: 'Page writes per second'
          type: DEPENDENT
          key: mssql.page_writes_sec.rate
          value_type: FLOAT
          description: 'Indicates the number of physical database page writes that are issued per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Page writes/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
            - tag: component
              value: performance
          triggers:
            - uuid: 548941f4a7cc4cadba64d8efd46655da
              expression: 'min(/MSSQL by ODBC/mssql.page_writes_sec.rate,5m)>{$MSSQL.PAGE_WRITES.MAX}'
              name: 'MSSQL: Number of physical database page writes per second is high'
              event_name: 'MSSQL: Number of physical database page writes per second is high (over {$MSSQL.PAGE_WRITES.MAX} for 5m)'
              priority: WARNING
              description: 'The physical database page writes are issued too frequently.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 76918163a16e4ad786bed2040acc8061
          name: 'Percent of ad hoc queries running'
          type: CALCULATED
          key: mssql.percent_of_adhoc_queries
          delay: 0;m0-59s3
          value_type: FLOAT
          units: '%'
          params: |
            last(//mssql.sql_compilations_sec.rate) * 100 /
            (last(//mssql.batch_requests_sec.rate) + (last(//mssql.batch_requests_sec.rate)=0))
          description: 'The ratio of SQL compilations per second to batch requests per second, in percent.'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: c5c1840220cd44fcaa7b47e0d52309bb
              expression: 'min(/MSSQL by ODBC/mssql.percent_of_adhoc_queries,15m) > {$MSSQL.PERCENT_COMPILATIONS.MAX}'
              name: 'MSSQL: Percent of ad hoc queries running is high'
              event_name: 'MSSQL: Percent of ad hoc queries running is over {$MSSQL.PERCENT_COMPILATIONS.MAX}% for 15m'
              priority: WARNING
              description: 'The lower this value is, the better. High values often indicate excessive ad hoc querying and should be as low as possible. If excessive ad hoc querying is happening, try rewriting the queries as procedures or invoke the queries using `sp_executeSQL`. When rewriting isn''t possible, consider using a plan guide or setting the database to parameterization forced mode.'
              tags:
                - tag: scope
                  value: performance
        - uuid: ceab0472883f47b0a18b04fc6f7438ab
          name: 'Percent of Recompiled Transact-SQL Objects'
          type: CALCULATED
          key: mssql.percent_recompilations_to_compilations
          delay: 0;m0-59s3
          value_type: FLOAT
          units: '%'
          params: |
            last(//mssql.sql_recompilations_sec.rate) * 100 /
            (last(//mssql.sql_compilations_sec.rate) + (last(//mssql.sql_compilations_sec.rate)=0))
          description: 'The ratio of SQL re-compilations per second to SQL compilations per second, in percent.'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: d5bad8ead8704e00bf332032e22ebfdd
              expression: 'min(/MSSQL by ODBC/mssql.percent_recompilations_to_compilations,15m) > {$MSSQL.PERCENT_RECOMPILATIONS.MAX}'
              name: 'MSSQL: Percent of times statement recompiles is high'
              event_name: 'MSSQL: Percent of times statement recompiles is over {$MSSQL.PERCENT_RECOMPILATIONS.MAX}% for 15m'
              priority: WARNING
              description: 'This number should be at or near zero, since recompiles can cause deadlocks and exclusive compile locks. This counter''s value should follow in proportion to "Batch Requests/sec" and "SQL Compilations/sec".'
              tags:
                - tag: scope
                  value: performance
        - uuid: 5c0bee24f9494bb49860171ff875caf7
          name: 'Number of blocked processes'
          type: DEPENDENT
          key: mssql.processes_blocked
          description: 'Number of currently blocked processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Processes blocked'')].cntr_value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: mssql.general_statistics.raw
          tags:
            - tag: component
              value: application
        - uuid: fc14b0c814234b12a3943eb0435cd28c
          name: 'Read-ahead pages per second'
          type: DEPENDENT
          key: mssql.readahead_pages_sec.rate
          value_type: FLOAT
          description: 'Indicates the number of pages read per second in anticipation of use.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Readahead pages/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
            - tag: component
              value: performance
        - uuid: be47be0cbb924982aaf9573c5a233144
          name: 'Safe auto-params per second'
          type: DEPENDENT
          key: mssql.safe_autoparams_sec.rate
          value_type: FLOAT
          description: 'Number of safe auto-parameterization attempts per second. Safe refers to a determination that a cached execution plan can be shared between different similar-looking Transact-SQL statements. SQL Server makes many auto-parameterization attempts, some of which turn out to be safe and others fail. Note that auto-parameterizations are also known as simple parameterizations in the newer versions of SQL Server. This does not include forced parameterizations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Safe Auto-Params/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: 9ce27df57ebc4ecca1a4741e66c9fba0
          name: 'Full scans to Index searches ratio'
          type: CALCULATED
          key: mssql.scan_to_search
          delay: 0;m0-59s3
          value_type: FLOAT
          params: 'last(//mssql.full_scans_sec.rate) / (last(//mssql.index_searches_sec.rate) + (last(//mssql.index_searches_sec.rate)=0))'
          description: 'The ratio of full scans per second to index searches per second. The threshold recommendation is strictly for OLTP workloads.'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 3c22a74a94d641389b57a6013ddd10cb
              expression: 'min(/MSSQL by ODBC/mssql.scan_to_search,15m) > 0.001'
              name: 'MSSQL: Number of index and table scans exceeds index searches in the last 15m'
              priority: WARNING
              description: 'Index searches are preferable to index and table scans. For OLTP applications, optimize for more index searches and less scans (preferably, 1 full scan for every 1000 index searches). Index and table scans are expensive I/O operations.'
              tags:
                - tag: scope
                  value: performance
        - uuid: e9ea451a38424f6b9da59b8bbb068b51
          name: 'SQL compilations per second'
          type: DEPENDENT
          key: mssql.sql_compilations_sec.rate
          value_type: FLOAT
          description: 'Number of SQL compilations per second. Indicates the number of times the compile code path is entered. Includes runs caused by statement-level recompilations in SQL Server. After SQL Server user activity is stable, this value reaches a steady state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''SQL Compilations/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: c7e0a26bf403482daec65a4b3cd0fd18
          name: 'Get SQL Errors counters'
          type: DEPENDENT
          key: mssql.sql_errors.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets SQL error information.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*SQL Errors'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: raw
        - uuid: a72415acabda46309c4dbc692e026cc2
          name: 'SQL re-compilations per second'
          type: DEPENDENT
          key: mssql.sql_recompilations_sec.rate
          value_type: FLOAT
          description: 'Number of statement recompiles per second. Counts the number of times statement recompiles are triggered. Generally, you want the recompiles to be low.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''SQL Re-Compilations/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: ca60d01d14d04566bf1a5e6b3b819538
          name: 'Get SQL Statistics counters'
          type: DEPENDENT
          key: mssql.sql_statistics.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets SQL statistics information.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*SQL Statistics'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 595aa3989b4e41cc8649827525adc0a0
          name: 'Table lock escalations per second'
          type: DEPENDENT
          key: mssql.table_lock_escalations.rate
          value_type: FLOAT
          description: 'Number of times locks on a table were escalated to the TABLE or HoBT granularity.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Table Lock Escalations/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: lock
            - tag: component
              value: performance
        - uuid: 37269b33e05349a1bfd05e4e493da6d4
          name: 'Target pages'
          type: DEPENDENT
          key: mssql.target_pages
          description: 'The optimal number of pages in the buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Target pages'')].cntr_value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
        - uuid: 2679f7e843e549ce9468f6cab05a71d5
          name: 'Target server memory'
          type: DEPENDENT
          key: mssql.target_server_memory
          units: B
          description: 'Indicates the ideal amount of memory the server can consume.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Target Server Memory (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: 8c7d63f3689f464394a6035a3cad4009
          name: 'Total latch wait time'
          type: DEPENDENT
          key: mssql.total_latch_wait_time
          value_type: FLOAT
          units: ms
          description: 'Total latch wait time (in milliseconds) for latch requests in the last second. This value should stay stable compared to the number of latch waits per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Total Latch Wait Time (ms)'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.latches_info.raw
          tags:
            - tag: component
              value: wait-time
        - uuid: 9112ed9b9d3741018d40f2dc892fa0f6
          name: 'Total server memory'
          type: DEPENDENT
          key: mssql.total_server_memory
          units: B
          description: 'Specifies the amount of memory the server has committed using the memory manager.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Total Server Memory (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: 273b373d8b41411fafcfd1e93bb8ce2c
          name: 'Total transactions number'
          type: DEPENDENT
          key: mssql.transactions
          description: 'The number of currently active transactions of all types.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Transactions'' && @.counter_name==''Transactions'')].cntr_value.first()'
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: transaction
        - uuid: 127e1f73ce414eeb87d2cbfef46ccdef
          name: 'Total transactions per second'
          type: DEPENDENT
          key: mssql.transactions_sec.rate
          value_type: FLOAT
          description: 'Total number of transactions started for all databases per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Transactions/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.db_info.raw
          tags:
            - tag: component
              value: performance
            - tag: component
              value: transaction
        - uuid: ef6450dfcb9a476ca1bf97524e05d43d
          name: 'Unsafe auto-params per second'
          type: DEPENDENT
          key: mssql.unsafe_autoparams_sec.rate
          value_type: FLOAT
          description: 'Number of unsafe auto-parameterization attempts per second. For example, the query has some characteristics that prevent the cached plan from being shared. These are designated as unsafe. This does not count the number of forced parameterizations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Unsafe Auto-Params/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: 27449e795c0a4e4e90c9ee6b6bf3df90
          name: Uptime
          type: DEPENDENT
          key: mssql.uptime
          trends: '0'
          units: uptime
          description: 'MSSQL Server uptime in the format "N days, hh:mm:ss".'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Uptime'')].cntr_value.first()'
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 0321c9f671394cb180fdce53b4033cf4
              expression: 'nodata(/MSSQL by ODBC/mssql.uptime,30m)=1'
              name: 'MSSQL: Failed to fetch info data'
              event_name: 'MSSQL: Failed to fetch info data (or no data for 30m)'
              priority: INFO
              description: 'Zabbix has not received any data for items for the last 30 minutes.'
              dependencies:
                - name: 'MSSQL: Service is unavailable'
                  expression: 'last(/MSSQL by ODBC/net.tcp.service[tcp,{$MSSQL.HOST},{$MSSQL.PORT}])=0'
              tags:
                - tag: scope
                  value: availability
            - uuid: aa10f863608a494281f41e12f0d2b1a5
              expression: 'last(/MSSQL by ODBC/mssql.uptime)<10m'
              name: 'MSSQL: Service has been restarted'
              event_name: 'MSSQL: Service has been restarted (uptime < 10m)'
              priority: INFO
              description: 'Uptime is less than 10 minutes.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 4e13bfc5927a421fb2996eec7e013448
          name: 'Number of users connected'
          type: DEPENDENT
          key: mssql.user_connections
          description: 'Number of users connected to MSSQL Server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''User Connections'')].cntr_value.first()'
          master_item:
            key: mssql.general_statistics.raw
          tags:
            - tag: component
              value: application
        - uuid: 5942cad838e8430a9ff71293dec52af8
          name: 'Errors per second (User errors)'
          type: DEPENDENT
          key: mssql.user_errors_sec.rate
          value_type: FLOAT
          description: 'Number of errors per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Errors/sec'' && @.instance_name==''User Errors'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_errors.raw
          tags:
            - tag: component
              value: error
            - tag: component
              value: performance
        - uuid: 7013504d4a6c4b40a0aab11dab15d107
          name: Version
          type: DEPENDENT
          key: mssql.version
          value_type: CHAR
          description: 'MSSQL Server version.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Version'')].instance_name.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 4ece2c9172714c68b8345834cc37d927
              expression: 'last(/MSSQL by ODBC/mssql.version,#1)<>last(/MSSQL by ODBC/mssql.version,#2) and length(last(/MSSQL by ODBC/mssql.version))>0'
              name: 'MSSQL: Version has changed'
              event_name: 'MSSQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              description: 'MSSQL version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: ea84affd97864dfaad7edf31e16e1300
          name: 'Work files created per second'
          type: DEPENDENT
          key: mssql.workfiles_created_sec.rate
          value_type: FLOAT
          description: 'Number of work files created per second. For example, work files can be used to store temporary results for hash joins and hash aggregates.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Workfiles Created/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: performance
          triggers:
            - uuid: 2f7e2dd4a94e4e92b468f4e2e2364f71
              expression: 'min(/MSSQL by ODBC/mssql.workfiles_created_sec.rate,5m)>{$MSSQL.WORK_FILES.MAX}'
              name: 'MSSQL: Number of work files created per second is high'
              event_name: 'MSSQL: Number of work files created per second is high (over {$MSSQL.WORK_FILES.MAX} for 5m)'
              priority: AVERAGE
              description: 'Too many work files created per second to store temporary results for hash joins and hash aggregates.'
              tags:
                - tag: scope
                  value: performance
        - uuid: a38e7fdf994842558227dfad03e9943b
          name: 'Work tables created per second'
          type: DEPENDENT
          key: mssql.worktables_created_sec.rate
          value_type: FLOAT
          description: 'Number of work tables created per second. For example, work tables can be used to store temporary results for query spool, LOB variables, XML variables, and cursors.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Worktables Created/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: performance
          triggers:
            - uuid: 0214004de3084ce6b35d5bba53a66947
              expression: 'min(/MSSQL by ODBC/mssql.worktables_created_sec.rate,5m)>{$MSSQL.WORK_TABLES.MAX}'
              name: 'MSSQL: Number of work tables created per second is high'
              event_name: 'MSSQL: Number of work tables created per second is high (over {$MSSQL.WORK_TABLES.MAX} for 5m)'
              priority: AVERAGE
              description: 'Too many work tables created per second to store temporary results for query spool, LOB variables, XML variables, and cursors.'
              tags:
                - tag: scope
                  value: performance
        - uuid: d93779b26c1a4784be31d32130eebf92
          name: 'Worktables from cache ratio'
          type: DEPENDENT
          key: mssql.worktables_from_cache_ratio
          value_type: FLOAT
          units: '%'
          description: 'Percentage of work tables created where the initial two pages of the work table were not allocated but were immediately available from the work table cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''WorktablesFromCacheRatio'')].cntr_value.first()'
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: cache
          triggers:
            - uuid: 98dee2bc42484988b208e100cc25ae05
              expression: 'max(/MSSQL by ODBC/mssql.worktables_from_cache_ratio,5m)<{$MSSQL.WORKTABLES_FROM_CACHE_RATIO.MIN.CRIT}'
              name: 'MSSQL: Percentage of work tables available from the work table cache is low'
              event_name: 'MSSQL: Percentage of work tables available from the work table cache is low (below {$MSSQL.WORKTABLES_FROM_CACHE_RATIO.MIN.CRIT}% for 5m)'
              priority: HIGH
              description: 'A value less than 90% may indicate insufficient memory, since execution plans are being dropped, or, on 32-bit systems, may indicate the need for an upgrade to a 64-bit system.'
              tags:
                - tag: scope
                  value: performance
        - uuid: c0302965c2574b43955a1d37a8fce9eb
          name: 'Service''s TCP port state'
          type: SIMPLE
          key: 'net.tcp.service[tcp,{$MSSQL.HOST},{$MSSQL.PORT}]'
          delay: 30s
          description: 'Test the availability of MSSQL Server on a TCP port.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: network
          triggers:
            - uuid: 152af5cc3ce04d4aa8ab255c37aed6c6
              expression: 'last(/MSSQL by ODBC/net.tcp.service[tcp,{$MSSQL.HOST},{$MSSQL.PORT}])=0'
              name: 'MSSQL: Service is unavailable'
              priority: DISASTER
              description: 'The TCP port of the MSSQL Server service is currently unavailable.'
              tags:
                - tag: scope
                  value: availability
      discovery_rules:
        - uuid: 6261715081794a49938d848c677da657
          name: 'Availability group discovery'
          type: DEPENDENT
          key: mssql.availability.group.discovery
          description: 'Discovery of the existing availability groups.'
          item_prototypes:
            - uuid: 381c88cf5b0c47319b036e79265b0a20
              name: 'MSSQL AG ''{#GROUP_NAME}'': Primary replica recovery health'
              type: DEPENDENT
              key: 'mssql.primary_recovery_health["{#GROUP_NAME}"]'
              description: |
                Indicates the recovery health of the primary replica:
                0 = In progress
                1 = Online
                2 = Unavailable
              valuemap:
                name: 'MSSQL AG Recovery health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.group_name==''{#GROUP_NAME}'')].primary_recovery_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_availability_group,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: availability-group
              trigger_prototypes:
                - uuid: c472a4f8400e451db529d5e12b863216
                  expression: 'last(/MSSQL by ODBC/mssql.primary_recovery_health["{#GROUP_NAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'': Primary replica recovery health in progress'
                  priority: WARNING
                  description: 'The primary replica is in the synchronization process.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: scope
                      value: notice
            - uuid: df51dcd0ef864705bc542e1233c1135b
              name: 'MSSQL AG ''{#GROUP_NAME}'': Primary replica name'
              type: DEPENDENT
              key: 'mssql.primary_replica["{#GROUP_NAME}"]'
              value_type: CHAR
              description: 'Name of the server instance that is hosting the current primary replica.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.group_name==''{#GROUP_NAME}'')].primary_replica.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'db.odbc.get[get_availability_group,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: availability-group
            - uuid: d2e76a734bd84484b6bd59b33c921f34
              name: 'MSSQL AG ''{#GROUP_NAME}'': Secondary replica recovery health'
              type: DEPENDENT
              key: 'mssql.secondary_recovery_health["{#GROUP_NAME}"]'
              description: |
                Indicates the recovery health of a secondary replica:
                0 = In progress
                1 = Online
                2 = Unavailable
              valuemap:
                name: 'MSSQL AG Recovery health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.group_name==''{#GROUP_NAME}'')].secondary_recovery_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_availability_group,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: availability-group
              trigger_prototypes:
                - uuid: 1fbf51eb9f8b432c8e0d9ec3af1cab44
                  expression: 'last(/MSSQL by ODBC/mssql.secondary_recovery_health["{#GROUP_NAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'': Secondary replica recovery health in progress'
                  priority: WARNING
                  description: 'The secondary replica is in the synchronization process.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: scope
                      value: notice
            - uuid: fe59d23d0ba44777b0abf1a35b2c014e
              name: 'MSSQL AG ''{#GROUP_NAME}'': Synchronization health'
              type: DEPENDENT
              key: 'mssql.synchronization_health["{#GROUP_NAME}"]'
              description: |
                Reflects a rollup of the `synchronization_health` of all availability replicas in the availability group:
                0 = Not healthy. None of the availability replicas have a healthy synchronization.
                1 = Partially healthy. The synchronization of some, but not all, availability replicas is healthy.
                2 = Healthy. The synchronization of every availability replica is healthy.
              valuemap:
                name: 'MSSQL AG Synchronization health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.group_name==''{#GROUP_NAME}'')].synchronization_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_availability_group,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: availability-group
              trigger_prototypes:
                - uuid: 2ee92e5ea41744ac9e27ffaa4313bdec
                  expression: 'last(/MSSQL by ODBC/mssql.synchronization_health["{#GROUP_NAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'': All replicas unhealthy'
                  priority: DISASTER
                  description: 'None of the availability replicas have a healthy synchronization.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: scope
                      value: availability
                - uuid: fd24c78f1db24186932d17d1145b6e92
                  expression: 'last(/MSSQL by ODBC/mssql.synchronization_health["{#GROUP_NAME}"])=1'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'': Some replicas unhealthy'
                  priority: HIGH
                  description: 'The synchronization health of some, but not all, availability replicas is healthy.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: scope
                      value: availability
          master_item:
            key: 'db.odbc.get[get_availability_group,"{$MSSQL.DSN}"]'
          lld_macro_paths:
            - lld_macro: '{#GROUP_NAME}'
              path: $.group_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: 2e38ea24c9bf4a5480df0816b7c659b3
          name: 'Database discovery'
          type: DEPENDENT
          key: mssql.database.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DBNAME}'
                value: '{$MSSQL.DBNAME.MATCHES}'
              - macro: '{#DBNAME}'
                value: '{$MSSQL.DBNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Scanning databases in DBMS.'
          item_prototypes:
            - uuid: 9c9dab20d8fa46f888c6aa7c7c9bf1b9
              name: 'MSSQL DB ''{#DBNAME}'': Last diff backup duration'
              type: DEPENDENT
              key: 'mssql.backup.diff.duration["{#DBNAME}"]'
              units: s
              description: 'Duration of the last differential backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''I'')].duration.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: bd663e1e9b40469cb4ca430186b049db
              name: 'MSSQL DB ''{#DBNAME}'': Last diff backup (time ago)'
              type: DEPENDENT
              key: 'mssql.backup.diff["{#DBNAME}"]'
              units: s
              description: 'The amount of time since the last differential backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''I'')].time_since_last_backup.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 036892c6b9de41c698a4e9acd5457e6a
                  expression: 'last(/MSSQL by ODBC/mssql.backup.diff["{#DBNAME}"])>{$MSSQL.BACKUP_DIFF.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_DIFF.USED:"{#DBNAME}"}=1'
                  name: 'MSSQL: DB ''{#DBNAME}'': Diff backup is old'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Diff backup older than {$MSSQL.BACKUP_DIFF.CRIT:"{#DBNAME}"}'
                  opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
                  priority: HIGH
                  description: 'The differential backup has not been executed for a long time.'
                  manual_close: 'YES'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
                - uuid: 9a294163ee034fc6a58f5534a7d79aac
                  expression: 'last(/MSSQL by ODBC/mssql.backup.diff["{#DBNAME}"])>{$MSSQL.BACKUP_DIFF.WARN:"{#DBNAME}"} and {$MSSQL.BACKUP_DIFF.USED:"{#DBNAME}"}=1'
                  name: 'MSSQL: DB ''{#DBNAME}'': Diff backup is old'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Diff backup older than {$MSSQL.BACKUP_DIFF.WARN:"{#DBNAME}"}'
                  opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
                  priority: WARNING
                  description: 'The differential backup has not been executed for a long time.'
                  manual_close: 'YES'
                  dependencies:
                    - name: 'MSSQL: DB ''{#DBNAME}'': Diff backup is old'
                      expression: 'last(/MSSQL by ODBC/mssql.backup.diff["{#DBNAME}"])>{$MSSQL.BACKUP_DIFF.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_DIFF.USED:"{#DBNAME}"}=1'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
            - uuid: 52929d988ad34aac945ff2ce9e448261
              name: 'MSSQL DB ''{#DBNAME}'': Last full backup duration'
              type: DEPENDENT
              key: 'mssql.backup.full.duration["{#DBNAME}"]'
              units: s
              description: 'Duration of the last full backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''D'')].duration.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 06d0ac1eeca843a289defa1cf1d728a3
              name: 'MSSQL DB ''{#DBNAME}'': Last full backup (time ago)'
              type: DEPENDENT
              key: 'mssql.backup.full["{#DBNAME}"]'
              units: s
              description: 'The amount of time since the last full backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''D'')].time_since_last_backup.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 09c8e059ffa44d0eb1be626b5d820dc9
                  expression: 'last(/MSSQL by ODBC/mssql.backup.full["{#DBNAME}"])>{$MSSQL.BACKUP_FULL.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_FULL.USED:"{#DBNAME}"}=1'
                  name: 'MSSQL: DB ''{#DBNAME}'': Full backup is old'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Full backup older than {$MSSQL.BACKUP_FULL.CRIT:"{#DBNAME}"}'
                  opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
                  priority: HIGH
                  description: 'The full backup has not been executed for a long time.'
                  manual_close: 'YES'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
                - uuid: b380d76b1055482ca8cd69c90611f1a5
                  expression: 'last(/MSSQL by ODBC/mssql.backup.full["{#DBNAME}"])>{$MSSQL.BACKUP_FULL.WARN:"{#DBNAME}"} and {$MSSQL.BACKUP_FULL.USED:"{#DBNAME}"}=1'
                  name: 'MSSQL: DB ''{#DBNAME}'': Full backup is old'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Full backup older than {$MSSQL.BACKUP_FULL.WARN:"{#DBNAME}"}'
                  opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
                  priority: WARNING
                  description: 'The full backup has not been executed for a long time.'
                  manual_close: 'YES'
                  dependencies:
                    - name: 'MSSQL: DB ''{#DBNAME}'': Full backup is old'
                      expression: 'last(/MSSQL by ODBC/mssql.backup.full["{#DBNAME}"])>{$MSSQL.BACKUP_FULL.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_FULL.USED:"{#DBNAME}"}=1'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 218241c7c5a648a59021999f97516349
              name: 'MSSQL DB ''{#DBNAME}'': Last log backup duration'
              type: DEPENDENT
              key: 'mssql.backup.log.duration["{#DBNAME}"]'
              units: s
              description: 'Duration of the last log backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''L'')].duration.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: c5e796bc904848efb2557c8a9a07b828
              name: 'MSSQL DB ''{#DBNAME}'': Last log backup (time ago)'
              type: DEPENDENT
              key: 'mssql.backup.log["{#DBNAME}"]'
              units: s
              description: 'The amount of time since the last log backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''L'')].time_since_last_backup.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: a6a276b5a8ce4b00b277e507ea7b15ee
              name: 'MSSQL DB ''{#DBNAME}'': Get last backup'
              type: DEPENDENT
              key: 'mssql.backup.raw["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'The item gets information about backup processes for {#DBNAME}.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')]'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'db.odbc.get[get_last_backup,"{$MSSQL.DSN}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 52a2d8012fea467582b09505e9c880be
              name: 'MSSQL DB ''{#DBNAME}'': Recovery model'
              type: DEPENDENT
              key: 'mssql.backup.recovery_model["{#DBNAME}"]'
              description: |
                Recovery model selected:
                1 = Full
                2 = Bulk_logged
                3 = Simple
              valuemap:
                name: 'MSSQL Recovery model'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[0].db_recovery_model'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '1'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: f4f218f22d6d48419260003880b38abd
              name: 'MSSQL DB ''{#DBNAME}'': Active transactions'
              type: DEPENDENT
              key: 'mssql.db.active_transactions["{#DBNAME}"]'
              description: 'Number of active transactions for the database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Active Transactions'')].cntr_value.first()'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: ff3916f807784639a1821229d4d722d8
              name: 'MSSQL DB ''{#DBNAME}'': Data file size'
              type: DEPENDENT
              key: 'mssql.db.data_files_size["{#DBNAME}"]'
              units: B
              description: 'Cumulative size of all the data files in the database including any automatic growth. Monitoring this counter is useful, for example, for determining the correct size of `tempdb`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Data File(s) Size (KB)'')].cntr_value.first()'
                - type: MULTIPLIER
                  parameters:
                    - '1024'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 0d7bdf4c18fa49e79926e6f6d078d50f
              name: 'MSSQL DB ''{#DBNAME}'': Log bytes flushed per second'
              type: DEPENDENT
              key: 'mssql.db.log_bytes_flushed_sec.rate["{#DBNAME}"]'
              value_type: FLOAT
              units: Bps
              description: 'Total number of log bytes flushed per second. Useful for determining trends and utilization of the transaction log.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Bytes Flushed/sec'')].cntr_value.first()'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 85536311e68047a6a8bf13c51c8d0647
              name: 'MSSQL DB ''{#DBNAME}'': Log file size'
              type: DEPENDENT
              key: 'mssql.db.log_files_size["{#DBNAME}"]'
              units: B
              description: 'Cumulative size of all the transaction log files in the database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log File(s) Size (KB)'')].cntr_value.first()'
                - type: MULTIPLIER
                  parameters:
                    - '1024'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 75fd2f42e274471c97cb23dc740863b8
              name: 'MSSQL DB ''{#DBNAME}'': Log file used size'
              type: DEPENDENT
              key: 'mssql.db.log_files_used_size["{#DBNAME}"]'
              units: B
              description: 'Cumulative size of all the log files in the database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log File(s) Used Size (KB)'')].cntr_value.first()'
                - type: MULTIPLIER
                  parameters:
                    - '1024'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: c10b6f364aa547d8b4abe431ae27d70b
              name: 'MSSQL DB ''{#DBNAME}'': Log flushes per second'
              type: DEPENDENT
              key: 'mssql.db.log_flushes_sec.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of log flushes per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Flushes/sec'')].cntr_value.first()'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 5404c8682b294a06a3027dc10d0b43fc
              name: 'MSSQL DB ''{#DBNAME}'': Log flush waits per second'
              type: DEPENDENT
              key: 'mssql.db.log_flush_waits_sec.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of commits per second waiting for the log flush.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Flush Waits/sec'')].cntr_value.first()'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: b351fc1128c24faf88d36717d0a0d1a5
                  expression: 'min(/MSSQL by ODBC/mssql.db.log_flush_waits_sec.rate["{#DBNAME}"],5m)>{$MSSQL.LOG_FLUSH_WAITS.MAX:"{#DBNAME}"}'
                  name: 'MSSQL: DB ''{#DBNAME}'': Number of commits waiting for the log flush is high'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Number of commits waiting for the log flush is high (over {$MSSQL.LOG_FLUSH_WAITS.MAX:"{#DBNAME}"}/sec for 5m)'
                  priority: WARNING
                  description: 'Too many commits are waiting for the log flush.'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: performance
            - uuid: f1abdb0800534f6bbf9f1403e7dea9e4
              name: 'MSSQL DB ''{#DBNAME}'': Log flush wait time'
              type: DEPENDENT
              key: 'mssql.db.log_flush_wait_time["{#DBNAME}"]'
              value_type: FLOAT
              units: ms
              description: 'Total wait time (in milliseconds) to flush the log. On an Always On secondary database, this value indicates the wait time for log records to be hardened to disk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Flush Wait Time'')].cntr_value.first()'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 80351c56215148b8ab75d95dc81ff0d0
                  expression: 'min(/MSSQL by ODBC/mssql.db.log_flush_wait_time["{#DBNAME}"],5m)>{$MSSQL.LOG_FLUSH_WAIT_TIME.MAX:"{#DBNAME}"}'
                  name: 'MSSQL: DB ''{#DBNAME}'': Total wait time to flush the log is high'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Total wait time to flush the log is high (over {$MSSQL.LOG_FLUSH_WAIT_TIME.MAX:"{#DBNAME}"}ms for 5m)'
                  priority: WARNING
                  description: 'The wait time to flush the log is too long.'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: performance
            - uuid: fdb24058e54243e8b5a888ec40d506e9
              name: 'MSSQL DB ''{#DBNAME}'': Log growths'
              type: DEPENDENT
              key: 'mssql.db.log_growths["{#DBNAME}"]'
              description: 'Total number of times the transaction log for the database has been expanded.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Growths'')].cntr_value.first()'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: a1a96d8bfef740ec9c8eadd9704ab605
              name: 'MSSQL DB ''{#DBNAME}'': Log shrinks'
              type: DEPENDENT
              key: 'mssql.db.log_shrinks["{#DBNAME}"]'
              description: 'Total number of times the transaction log for the database has been shrunk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Shrinks'')].cntr_value.first()'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 26d1515df1be450e861e4f7a9f76b03d
              name: 'MSSQL DB ''{#DBNAME}'': Log truncations'
              type: DEPENDENT
              key: 'mssql.db.log_truncations["{#DBNAME}"]'
              description: 'Number of times the transaction log has been shrunk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Truncations'')].cntr_value.first()'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 9f9cda56992841408ab8307b7019b76f
              name: 'MSSQL DB ''{#DBNAME}'': Percent log used'
              type: DEPENDENT
              key: 'mssql.db.percent_log_used["{#DBNAME}"]'
              value_type: FLOAT
              units: '%'
              description: 'Percentage of log space in use.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Percent Log Used'')].cntr_value.first()'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: f02958e3ee174c6dbe900e3dd92cacdc
                  expression: 'min(/MSSQL by ODBC/mssql.db.percent_log_used["{#DBNAME}"],5m)>{$MSSQL.PERCENT_LOG_USED.MAX:"{#DBNAME}"}'
                  name: 'MSSQL: DB ''{#DBNAME}'': Percent of log usage is high'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Percent of log usage is high (over {$MSSQL.PERCENT_LOG_USED.MAX:"{#DBNAME}"}% for 5m)'
                  priority: WARNING
                  description: 'There''s not enough space left in the log.'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: performance
            - uuid: 74b107e240274c69ae1e8f0632b67e14
              name: 'MSSQL DB ''{#DBNAME}'': Get performance counters'
              type: DEPENDENT
              key: 'mssql.db.perf_raw["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'The item gets server status information for {#DBNAME}.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.object_name=~''.*Databases'' && @.instance_name==''{#DBNAME}'')]'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'db.odbc.get[get_status_variables,"{$MSSQL.DSN}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: fe7d7c3e0aab43d79c00eaceb39c8c6c
              name: 'MSSQL DB ''{#DBNAME}'': State'
              type: DEPENDENT
              key: 'mssql.db.state["{#DBNAME}"]'
              description: |
                0 = Online
                1 = Restoring
                2 = Recovering | SQL Server 2008 and later
                3 = Recovery_pending | SQL Server 2008 and later
                4 = Suspect
                5 = Emergency | SQL Server 2008 and later
                6 = Offline | SQL Server 2008 and later
                7 = Copying | Azure SQL Database Active Geo-Replication
                10 = Offline_secondary | Azure SQL Database Active Geo-Replication
              valuemap:
                name: 'MSSQL DB state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''State'')].cntr_value.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 6b8c8cf8e0d24b7f8d9aa7469a0facd4
                  expression: 'last(/MSSQL by ODBC/mssql.db.state["{#DBNAME}"])>1'
                  name: 'MSSQL: DB ''{#DBNAME}'': State is {ITEM.VALUE}'
                  priority: HIGH
                  description: 'The DB has a non-working state.'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
            - uuid: 267b1d54c40641f5aeb4e3e7adfa4680
              name: 'MSSQL DB ''{#DBNAME}'': Transactions per second'
              type: DEPENDENT
              key: 'mssql.db.transactions_sec.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of transactions started for the database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Transactions/sec'')].cntr_value.first()'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
          trigger_prototypes:
            - uuid: 4a6e76dc9a5148649d07e35e962b5893
              expression: 'last(/MSSQL by ODBC/mssql.backup.log["{#DBNAME}"])>{$MSSQL.BACKUP_LOG.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_LOG.USED:"{#DBNAME}"}=1 and last(/MSSQL by ODBC/mssql.backup.recovery_model["{#DBNAME}"])<>3'
              name: 'MSSQL: DB ''{#DBNAME}'': Log backup is old'
              event_name: 'MSSQL: DB ''{#DBNAME}'': Log backup older than {$MSSQL.BACKUP_LOG.CRIT:"{#DBNAME}"}'
              opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The log backup has not been executed for a long time.'
              manual_close: 'YES'
              tags:
                - tag: database
                  value: '{#DBNAME}'
                - tag: scope
                  value: availability
            - uuid: 6000420450cf453bae3652c7f7d05e2b
              expression: 'last(/MSSQL by ODBC/mssql.backup.log["{#DBNAME}"])>{$MSSQL.BACKUP_LOG.WARN:"{#DBNAME}"} and {$MSSQL.BACKUP_LOG.USED:"{#DBNAME}"}=1 and last(/MSSQL by ODBC/mssql.backup.recovery_model["{#DBNAME}"])<>3'
              name: 'MSSQL: DB ''{#DBNAME}'': Log backup is old'
              event_name: 'MSSQL: DB ''{#DBNAME}'': Log backup older than {$MSSQL.BACKUP_LOG.WARN:"{#DBNAME}"}'
              opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The log backup has not been executed for a long time.'
              manual_close: 'YES'
              dependencies:
                - name: 'MSSQL: DB ''{#DBNAME}'': Log backup is old'
                  expression: 'last(/MSSQL by ODBC/mssql.backup.log["{#DBNAME}"])>{$MSSQL.BACKUP_LOG.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_LOG.USED:"{#DBNAME}"}=1 and last(/MSSQL by ODBC/mssql.backup.recovery_model["{#DBNAME}"])<>3'
              tags:
                - tag: database
                  value: '{#DBNAME}'
                - tag: scope
                  value: availability
          graph_prototypes:
            - uuid: ac52c952ba954065bbbb5c722630cd0b
              name: 'DB ''{#DBNAME}'': Log size'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'MSSQL by ODBC'
                    key: 'mssql.db.log_files_size["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'MSSQL by ODBC'
                    key: 'mssql.db.log_files_used_size["{#DBNAME}"]'
            - uuid: 49d3be5c3ce34cfc9c13456a2ae301f6
              name: 'DB ''{#DBNAME}'': Number of Log changes'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'MSSQL by ODBC'
                    key: 'mssql.db.log_growths["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'MSSQL by ODBC'
                    key: 'mssql.db.log_shrinks["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'MSSQL by ODBC'
                    key: 'mssql.db.log_truncations["{#DBNAME}"]'
            - uuid: 9553b9169f5e441abecfde1c07ca1a4e
              name: 'DB ''{#DBNAME}'': Size'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'MSSQL by ODBC'
                    key: 'mssql.db.data_files_size["{#DBNAME}"]'
          master_item:
            key: 'db.odbc.get[get_database,"{$MSSQL.DSN}"]'
          lld_macro_paths:
            - lld_macro: '{#DBNAME}'
              path: $.dbname
            - lld_macro: '{#RECOVERY_MODEL}'
              path: $.recovery_model
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          overrides:
            - name: 'Log backup'
              step: '1'
              filter:
                conditions:
                  - macro: '{#RECOVERY_MODEL}'
                    value: '3'
              operations:
                - operationobject: TRIGGER_PROTOTYPE
                  operator: LIKE
                  value: 'Log backup is old'
                  discover: NO_DISCOVER
        - uuid: 6d972c575a944d49badfc2e6a614f686
          name: 'Job discovery'
          type: DEPENDENT
          key: mssql.job.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#JOBNAME}'
                value: '{$MSSQL.JOB.MATCHES}'
              - macro: '{#JOBNAME}'
                value: '{$MSSQL.JOB.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Scanning jobs in DBMS.'
          item_prototypes:
            - uuid: 4e1e21603b01420f9b25e85f5987e7ec
              name: 'MSSQL Job ''{#JOBNAME}'': Enabled'
              type: DEPENDENT
              key: 'mssql.job.enabled["{#JOBNAME}"]'
              description: |
                The possible values of the job status:
                0 = Disabled
                1 = Enabled
              valuemap:
                name: 'MSSQL - Yes / No'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.enabled
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
            - uuid: 3ceba63a77e24628a2ee9439d574bac5
              name: 'MSSQL Job ''{#JOBNAME}'': Last run date-time'
              type: DEPENDENT
              key: 'mssql.job.lastrundatetime["{#JOBNAME}"]'
              units: unixtime
              description: 'The last date-time of the job run.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.last_run_date_time
                - type: JAVASCRIPT
                  parameters:
                    - 'return value == ''null'' ? 0 : Math.floor(new Date(value) / 1000);'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
            - uuid: b9984c1238554a559b444853e9f66653
              name: 'MSSQL Job ''{#JOBNAME}'': Last run status message'
              type: DEPENDENT
              key: 'mssql.job.lastrunstatusmessage["{#JOBNAME}"]'
              value_type: TEXT
              description: 'An informational message about the last run of the job.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.last_run_status_message
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
            - uuid: 1c725adad98f44158b43127d4c5fb0f3
              name: 'MSSQL Job ''{#JOBNAME}'': Next run date-time'
              type: DEPENDENT
              key: 'mssql.job.nextrundatetime["{#JOBNAME}"]'
              units: unixtime
              description: 'The next date-time of the job run.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.next_run_date_time
                - type: JAVASCRIPT
                  parameters:
                    - 'return value == ''null'' ? 0 : Math.floor(new Date(value) / 1000);'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
            - uuid: eaa43a261e114979af236698ea7ae32c
              name: 'MSSQL Job ''{#JOBNAME}'': Run status'
              type: DEPENDENT
              key: 'mssql.job.runstatus["{#JOBNAME}"]'
              description: |
                The possible values of the job status:
                0 ⇒ Failed
                1 ⇒ Succeeded
                2 ⇒ Retry
                3 ⇒ Canceled
                4 ⇒ Running
              valuemap:
                name: 'MSSQL Job Run Status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.run_status
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
              trigger_prototypes:
                - uuid: 304f468605164fd2baa1905cedf2c897
                  expression: 'last(/MSSQL by ODBC/mssql.job.runstatus["{#JOBNAME}"])=0'
                  name: 'MSSQL: Job ''{#JOBNAME}'': Failed to run'
                  priority: WARNING
                  description: 'The last run of the job has failed.'
                  manual_close: 'YES'
                  tags:
                    - tag: mssql-job
                      value: '{#JOBNAME}'
                    - tag: scope
                      value: performance
            - uuid: 69da58fe4c7e42028fa96388df526103
              name: 'MSSQL Job ''{#JOBNAME}'': Run duration'
              type: DEPENDENT
              key: 'mssql.job.run_duration["{#JOBNAME}"]'
              units: s
              description: 'Duration of the last-run job.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.run_duration
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
              trigger_prototypes:
                - uuid: 7e45cb8f41114388ac8772006d929da2
                  expression: 'last(/MSSQL by ODBC/mssql.job.run_duration["{#JOBNAME}"])>{$MSSQL.BACKUP_DURATION.WARN:"{#JOBNAME}"}'
                  name: 'MSSQL: Job ''{#JOBNAME}'': Job duration is high'
                  event_name: 'MSSQL: Job ''{#JOBNAME}'': Job duration is greater than {$MSSQL.BACKUP_DURATION.WARN:"{#JOBNAME}"}'
                  opdata: 'Job duration: {ITEM.LASTVALUE1}'
                  priority: WARNING
                  description: 'The job is taking too long.'
                  manual_close: 'YES'
                  tags:
                    - tag: mssql-job
                      value: '{#JOBNAME}'
                    - tag: scope
                      value: performance
            - uuid: 3660503b46be4c92a7b1d5040bc8cd0d
              name: 'MSSQL Job ''{#JOBNAME}'': Get job status'
              type: DEPENDENT
              key: 'mssql.job.status_raw["{#JOBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'The item gets the status of SQL agent job {#JOBNAME}.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.job_name==''{#JOBNAME}'')].first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'db.odbc.get[get_job_status,"{$MSSQL.DSN}"]'
              tags:
                - tag: component
                  value: raw
                - tag: mssql-job
                  value: '{#JOBNAME}'
          master_item:
            key: 'db.odbc.get[get_job_status,"{$MSSQL.DSN}"]'
          lld_macro_paths:
            - lld_macro: '{#JOBNAME}'
              path: $.job_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: af25f87b29c24c05a57a82f7b1347ad4
          name: 'Local database discovery'
          type: DEPENDENT
          key: mssql.local.db.discovery
          description: 'Discovery of the local availability databases.'
          item_prototypes:
            - uuid: 7e4baf2802394b93bf5770f4f72d7f05
              name: 'MSSQL AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': Suspended'
              type: DEPENDENT
              key: 'mssql.local_db.is_suspended["{#DBNAME}"]'
              description: |
                Database state:
                0 = Resumed
                1 = Suspended
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'' && @.group_name==''{#GROUP_NAME}'')].is_suspended.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_local_db,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: local-db
                - tag: local-db
                  value: '{#DBNAME}'
            - uuid: f8111429599e49bd947a12b9771d1a3d
              name: 'MSSQL AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': State'
              type: DEPENDENT
              key: 'mssql.local_db.state["{#DBNAME}"]'
              description: |
                0 = Online
                1 = Restoring
                2 = Recovering
                3 = Recovery pending
                4 = Suspect
                5 = Emergency
                6 = Offline
              valuemap:
                name: 'MSSQL DB state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'' && @.group_name==''{#GROUP_NAME}'')].database_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_local_db,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: local-db
                - tag: local-db
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 78923c9c52e74c80a77d418afe9e438d
                  expression: 'last(/MSSQL by ODBC/mssql.local_db.state["{#DBNAME}"])>0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': "{#DBNAME}" is {ITEM.VALUE}'
                  priority: WARNING
                  description: 'The local availability database has a non-working state.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: local-db
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
            - uuid: e7d7fbac95e94c45b6515c8e1b7baf1a
              name: 'MSSQL AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': Synchronization health'
              type: DEPENDENT
              key: 'mssql.local_db.synchronization_health["{#DBNAME}"]'
              description: |
                Reflects the intersection of the synchronization state of a database that is joined to the availability group on the availability replica and the availability mode of the availability replica (synchronous-commit or asynchronous-commit mode):
                0 = Not healthy. The synchronization_state of the database is 0 ("Not synchronizing").
                1 = Partially healthy. A database on a synchronous-commit availability replica is considered partially healthy if synchronization_state is 1 ("Synchronizing").
                2 = Healthy. A database on an synchronous-commit availability replica is considered healthy if synchronization_state is 2 ("Synchronized"), and a database on an asynchronous-commit availability replica is considered healthy if synchronization_state is 1 ("Synchronizing").
              valuemap:
                name: 'MSSQL AG Synchronization health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'' && @.group_name==''{#GROUP_NAME}'')].synchronization_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_local_db,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: local-db
                - tag: local-db
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: e51c10f9d86d458da9fdb7e21b4e0102
                  expression: 'last(/MSSQL by ODBC/mssql.local_db.synchronization_health["{#DBNAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': "{#DBNAME}" is Not healthy'
                  priority: HIGH
                  description: 'The synchronization state of the local availability database is "Not synchronizing".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: local-db
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
                - uuid: dc636f10f12c4f1ead597eca778561ec
                  expression: 'last(/MSSQL by ODBC/mssql.local_db.synchronization_health["{#DBNAME}"])=1'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': "{#DBNAME}" is Partially healthy'
                  priority: AVERAGE
                  description: 'A database on a synchronous-commit availability replica is considered partially healthy if synchronization state is "Synchronizing".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: local-db
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
          master_item:
            key: 'db.odbc.get[get_local_db,"{$MSSQL.DSN}"]'
          lld_macro_paths:
            - lld_macro: '{#DBNAME}'
              path: $.dbname
            - lld_macro: '{#GROUP_NAME}'
              path: $.group_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: d247eb5485f145ff9487424371a802b7
          name: 'Mirroring discovery'
          type: DEPENDENT
          key: mssql.mirroring.discovery
          description: 'To see the row for a database other than master or tempdb, you must either be the database owner or have at least ALTER ANY DATABASE or VIEW ANY DATABASE server-level permission or CREATE DATABASE permission in the master database. To see non-NULL values on a mirror database, you must be a member of the sysadmin fixed server role.'
          item_prototypes:
            - uuid: faccb61c8215482ab375c03444a0e8fd
              name: 'MSSQL Mirroring ''{#DBNAME}'': Role'
              type: DEPENDENT
              key: 'mssql.mirroring.role["{#DBNAME}"]'
              description: |
                Current role of the local database plays in the database mirroring session.
                1 = Principal
                2 = Mirror
              valuemap:
                name: 'MSSQL Mirroring Role'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')].mirroring_role.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_db_mirroring,"{$MSSQL.DSN}"]'
              tags:
                - tag: component
                  value: mssql-mirroring
                - tag: mssql-mirroring
                  value: '{#DBNAME}'
            - uuid: 19cdd945ced447d28b7480c07c1f61bc
              name: 'MSSQL Mirroring ''{#DBNAME}'': Role sequence'
              type: DEPENDENT
              key: 'mssql.mirroring.role_sequence["{#DBNAME}"]'
              description: 'The number of times that mirroring partners have switched the principal and mirror roles due to a failover or forced service.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')].mirroring_role_sequence.first()'
                - type: SIMPLE_CHANGE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_db_mirroring,"{$MSSQL.DSN}"]'
              tags:
                - tag: component
                  value: mssql-mirroring
                - tag: mssql-mirroring
                  value: '{#DBNAME}'
            - uuid: bedb23d788074424afdb2751c8a7e2b7
              name: 'MSSQL Mirroring ''{#DBNAME}'': Safety level'
              type: DEPENDENT
              key: 'mssql.mirroring.safety_level["{#DBNAME}"]'
              description: |
                Safety setting for updates on the mirror database:
                0 = Unknown state
                1 = Off [asynchronous]
                2 = Full [synchronous]
              valuemap:
                name: 'MSSQL Safety level'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')].mirroring_safety_level.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_db_mirroring,"{$MSSQL.DSN}"]'
              tags:
                - tag: component
                  value: mssql-mirroring
                - tag: mssql-mirroring
                  value: '{#DBNAME}'
            - uuid: 5df06f00a6194242af45ff5cccf43988
              name: 'MSSQL Mirroring ''{#DBNAME}'': State'
              type: DEPENDENT
              key: 'mssql.mirroring.state["{#DBNAME}"]'
              description: |
                State of the mirror database and of the database mirroring session.
                0 = Suspended
                1 = Disconnected from the other partner
                2 = Synchronizing
                3 = Pending failover
                4 = Synchronized
                5 = The partners are not synchronized. Failover is not possible now.
                6 = The partners are synchronized. Failover is potentially possible. For information about the requirements for the failover, see Database Mirroring Operating Modes: https://learn.microsoft.com/en-us/sql/database-engine/database-mirroring/database-mirroring-operating-modes?view=sql-server-ver16.
              valuemap:
                name: 'MSSQL Mirroring State'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')].mirroring_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_db_mirroring,"{$MSSQL.DSN}"]'
              tags:
                - tag: component
                  value: mssql-mirroring
                - tag: mssql-mirroring
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 323543b0df0e474abf9190a9630242b1
                  expression: 'last(/MSSQL by ODBC/mssql.mirroring.state["{#DBNAME}"])=3'
                  name: 'MSSQL: Mirroring ''{#DBNAME}'': "{#DBNAME}" is {ITEM.VALUE}'
                  priority: WARNING
                  description: 'The state of the mirror database and of the database mirroring session is "Pending failover".'
                  tags:
                    - tag: mssql-mirroring
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
                - uuid: 9a2bcdfb32654a55b8a75c8bf4331950
                  expression: 'last(/MSSQL by ODBC/mssql.mirroring.state["{#DBNAME}"])=5'
                  name: 'MSSQL: Mirroring ''{#DBNAME}'': "{#DBNAME}" is {ITEM.VALUE}'
                  priority: HIGH
                  description: 'The state of the mirror database and of the database mirroring session is "Not synchronized". The partners are not synchronized. A failover is not possible now.'
                  tags:
                    - tag: mssql-mirroring
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
                - uuid: c673a7c4820840528a4aa1771a5a56d4
                  expression: 'last(/MSSQL by ODBC/mssql.mirroring.state["{#DBNAME}"])>=0 and last(/MSSQL by ODBC/mssql.mirroring.state["{#DBNAME}"])<=2'
                  name: 'MSSQL: Mirroring ''{#DBNAME}'': "{#DBNAME}" is {ITEM.VALUE}'
                  priority: INFO
                  description: 'The state of the mirror database and of the database mirroring session is "Suspended", "Disconnected from the other partner", or "Synchronizing".'
                  tags:
                    - tag: mssql-mirroring
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
            - uuid: 7e4763d493a745e99082ca71a54c23c2
              name: 'MSSQL Mirroring ''{#DBNAME}'': Witness state'
              type: DEPENDENT
              key: 'mssql.mirroring.witness_state["{#DBNAME}"]'
              description: |
                State of the witness in the database mirroring session of the database:
                0 = Unknown
                1 = Connected
                2 = Disconnected
              valuemap:
                name: 'MSSQL Witness state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')].mirroring_witness_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_db_mirroring,"{$MSSQL.DSN}"]'
              tags:
                - tag: component
                  value: mssql-mirroring
                - tag: mssql-mirroring
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: ec374424b79346c99f1d815e0815c799
                  expression: 'last(/MSSQL by ODBC/mssql.mirroring.witness_state["{#DBNAME}"])=2'
                  name: 'MSSQL: Mirroring ''{#DBNAME}'': "{#DBNAME}" Witness is disconnected'
                  priority: WARNING
                  description: 'The state of the witness in the database mirroring session of the database is "Disconnected".'
                  tags:
                    - tag: mssql-mirroring
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
          graph_prototypes:
            - uuid: 9bf9203bd4b449b39e288fbb79f9d627
              name: 'Mirroring ''{#DBNAME}'': States'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'MSSQL by ODBC'
                    key: 'mssql.mirroring.state["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'MSSQL by ODBC'
                    key: 'mssql.mirroring.witness_state["{#DBNAME}"]'
          master_item:
            key: 'db.odbc.get[get_db_mirroring,"{$MSSQL.DSN}"]'
          lld_macro_paths:
            - lld_macro: '{#DBNAME}'
              path: $.dbname
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: dcf4eae19c7043fc85f7ec414502ef84
          name: 'Non-local database discovery'
          type: DEPENDENT
          key: mssql.non.local.db.discovery
          description: 'Discovery of the non-local (not local to SQL Server instance) availability databases.'
          item_prototypes:
            - uuid: 32d3797d6b22413e98aa206d3092947f
              name: 'MSSQL AG ''{#GROUP_NAME}'' Non-Local DB ''*{#REPLICA_NAME}*{#DBNAME}'': Log queue size'
              type: DEPENDENT
              key: 'mssql.non-local_db.log_send_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"]'
              units: B
              description: 'Amount of the log records of the primary database that has not been sent to the secondary databases.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'' && @.group_name==''{#GROUP_NAME}'' && @.replica_name==''{#REPLICA_NAME}'')].log_send_queue_size.first()'
                - type: MULTIPLIER
                  parameters:
                    - '1024'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_non_local_db,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: non-local-db
                - tag: non-local-db
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: def3b1d47dac4d039bffcc78f955b433
                  expression: 'last(/MSSQL by ODBC/mssql.non-local_db.log_send_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#1)>last(/MSSQL by ODBC/mssql.non-local_db.log_send_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#2) and last(/MSSQL by ODBC/mssql.non-local_db.log_send_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#2)>last(/MSSQL by ODBC/mssql.non-local_db.log_send_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#3)'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Non-Local DB ''*{#REPLICA_NAME}*{#DBNAME}'': Log queue size is growing'
                  priority: HIGH
                  description: 'The log records of the primary database are not sent to the secondary databases.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: non-local-db
                      value: '{#DBNAME}'
                    - tag: scope
                      value: capacity
            - uuid: 66d9735553754192bb9acf7b27c1501f
              name: 'MSSQL AG ''{#GROUP_NAME}'' Non-Local DB ''*{#REPLICA_NAME}*{#DBNAME}'': Redo log queue size'
              type: DEPENDENT
              key: 'mssql.non-local_db.redo_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"]'
              units: B
              description: 'Amount of log records in the log files of the secondary replica that has not yet been redone.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'' && @.group_name==''{#GROUP_NAME}'' && @.replica_name==''{#REPLICA_NAME}'')].redo_queue_size.first()'
                - type: MULTIPLIER
                  parameters:
                    - '1024'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_non_local_db,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: non-local-db
                - tag: non-local-db
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 2102f244f58b4fe981d569fe0fe599a9
                  expression: 'last(/MSSQL by ODBC/mssql.non-local_db.redo_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#1)>last(/MSSQL by ODBC/mssql.non-local_db.redo_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#2) and last(/MSSQL by ODBC/mssql.non-local_db.redo_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#2)>last(/MSSQL by ODBC/mssql.non-local_db.redo_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#3)'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Non-Local DB ''*{#REPLICA_NAME}*{#DBNAME}'': Redo log queue size is growing'
                  priority: HIGH
                  description: 'The log records in the log files of the secondary replica have not yet been redone.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: non-local-db
                      value: '{#DBNAME}'
                    - tag: scope
                      value: capacity
          master_item:
            key: 'db.odbc.get[get_non_local_db,"{$MSSQL.DSN}"]'
          lld_macro_paths:
            - lld_macro: '{#DBNAME}'
              path: $.dbname
            - lld_macro: '{#GROUP_NAME}'
              path: $.group_name
            - lld_macro: '{#REPLICA_NAME}'
              path: $.replica_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: baed17bf5a4846439e720388c9ae7c17
          name: 'Quorum discovery'
          type: DEPENDENT
          key: mssql.quorum.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CLUSTER_NAME}'
                value: ^.+$
          description: 'Discovery of the quorum of the WSFC cluster.'
          item_prototypes:
            - uuid: 6c30ce79872d4bb2b27965acd277e1e9
              name: 'MSSQL Cluster ''{#CLUSTER_NAME}'': Quorum state'
              type: DEPENDENT
              key: 'mssql.quorum.state.[{#CLUSTER_NAME}]'
              description: |
                State of the WSFC quorum, one of:
                0 = Unknown quorum state
                1 = Normal quorum
                2 = Forced quorum
              valuemap:
                name: 'MSSQL Quorum state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.cluster_name==''{#CLUSTER_NAME}'')].quorum_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_quorum,"{$MSSQL.DSN}"]'
              tags:
                - tag: cluster-name
                  value: '{#CLUSTER_NAME}'
                - tag: component
                  value: quorum
            - uuid: 4d7f29272d1c4889bae0aa50bcd31e9c
              name: 'MSSQL Cluster ''{#CLUSTER_NAME}'': Quorum type'
              type: DEPENDENT
              key: 'mssql.quorum.type.[{#CLUSTER_NAME}]'
              description: |
                Type of quorum used by this WSFC cluster, one of:
                0 = Node Majority. This quorum configuration can sustain failures of half the nodes (rounding up) minus one.
                1 = Node and Disk Majority. If the disk witness remains on line, this quorum configuration can sustain failures of half the nodes (rounding up).
                2 = Node and File Share Majority. This quorum configuration works in a similar way to Node and Disk Majority, but uses a file-share witness instead of a disk witness.
                3 = No Majority: Disk Only. If the quorum disk is online, this quorum configuration can sustain failures of all nodes except one.
                4 = Unknown Quorum. Unknown quorum for the cluster.
                5 = Cloud Witness. Cluster utilizes Microsoft Azure for quorum arbitration. If the cloud witness is available, the cluster can sustain the failure of half the nodes (rounding up).
              valuemap:
                name: 'MSSQL Quorum type'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.cluster_name==''{#CLUSTER_NAME}'')].quorum_type.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'db.odbc.get[get_quorum,"{$MSSQL.DSN}"]'
              tags:
                - tag: cluster-name
                  value: '{#CLUSTER_NAME}'
                - tag: component
                  value: quorum
          master_item:
            key: 'db.odbc.get[get_quorum,"{$MSSQL.DSN}"]'
          lld_macro_paths:
            - lld_macro: '{#CLUSTER_NAME}'
              path: $.cluster_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: 1ea73914e10e407abe3b4e715f6759b4
          name: 'Quorum members discovery'
          type: DEPENDENT
          key: mssql.quorum.member.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CLUSTER_NAME}'
                value: ^.+$
              - macro: '{#MEMBER_NAME}'
                value: '{$MSSQL.QUORUM.MEMBER.DISCOVERY.NAME.MATCHES}'
              - macro: '{#MEMBER_NAME}'
                value: '{$MSSQL.QUORUM.MEMBER.DISCOVERY.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery of the quorum members of the WSFC cluster.'
          item_prototypes:
            - uuid: 0dc6b43da4854b1cbb41ad0d5c5079a9
              name: 'MSSQL Cluster member ''{#MEMBER_NAME}'': Member state'
              type: DEPENDENT
              key: 'mssql.quorum_members.member_state.[{#MEMBER_NAME}]'
              description: |
                The member state, one of:
                0 = Offline
                1 = Online
              valuemap:
                name: 'MSSQL Quorum members state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.member_name==''{#MEMBER_NAME}'')].member_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_quorum_member,"{$MSSQL.DSN}"]'
              tags:
                - tag: component
                  value: 'quorum members'
                - tag: quorum-members-name
                  value: '{#MEMBER_NAME}'
            - uuid: 337cd4bfedc846048fc366bb7cf1bebd
              name: 'MSSQL Cluster member ''{#MEMBER_NAME}'': Member type'
              type: DEPENDENT
              key: 'mssql.quorum_members.member_type.[{#MEMBER_NAME}]'
              description: |
                The type of member, one of:
                0 = WSFC node
                1 = Disk witness
                2 = File share witness
                3 = Cloud Witness
              valuemap:
                name: 'MSSQL Quorum members type'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.member_name==''{#MEMBER_NAME}'')].member_type.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'db.odbc.get[get_quorum_member,"{$MSSQL.DSN}"]'
              tags:
                - tag: component
                  value: 'quorum members'
                - tag: quorum-members-name
                  value: '{#MEMBER_NAME}'
            - uuid: d8fff68f86494892bbe1cb2c6b281075
              name: 'MSSQL Cluster member ''{#MEMBER_NAME}'': Number of quorum votes'
              type: DEPENDENT
              key: 'mssql.quorum_members.number_of_quorum_votes.[{#MEMBER_NAME}]'
              description: 'Number of quorum votes possessed by this quorum member.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.member_name==''{#MEMBER_NAME}'')].number_of_quorum_votes.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'db.odbc.get[get_quorum_member,"{$MSSQL.DSN}"]'
              tags:
                - tag: component
                  value: 'quorum members'
                - tag: quorum-members-name
                  value: '{#MEMBER_NAME}'
          master_item:
            key: 'db.odbc.get[get_quorum_member,"{$MSSQL.DSN}"]'
          lld_macro_paths:
            - lld_macro: '{#CLUSTER_NAME}'
              path: $.cluster_name
            - lld_macro: '{#MEMBER_NAME}'
              path: $.member_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: 024656ffe254416781cb4ad52ae456ea
          name: 'Replication discovery'
          type: DEPENDENT
          key: mssql.replica.discovery
          description: 'Discovery of the database replicas.'
          item_prototypes:
            - uuid: 7403de703b024d428edfc59f3aa9181b
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Connected state'
              type: DEPENDENT
              key: 'mssql.replica.connected_state["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Whether a secondary replica is currently connected to the primary replica:
                0 = Disconnected. The response of an availability replica to the "Disconnected" state depends on its role:
                On the primary replica, if a secondary replica is disconnected, its secondary databases are marked as "Not synchronized" on the primary replica, which waits for the secondary to reconnect;
                On a secondary replica, upon detecting that it is disconnected, the secondary replica attempts to reconnect to the primary replica.
                1 = Connected. Each primary replica tracks the connection state for every secondary replica in the same availability group. Secondary replicas track the connection state of only the primary replica.
              valuemap:
                name: 'MSSQL AG Connected state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].connected_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_replica,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
            - uuid: 51cb8f4fe5954c0ea21eff6102034862
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Is local'
              type: DEPENDENT
              key: 'mssql.replica.is_local["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Whether the replica is local:
                0 = Indicates a remote secondary replica in an availability group whose primary replica is hosted by the local server instance. This value occurs only on the primary replica location.
                1 = Indicates a local replica. On secondary replicas, this is the only available value for the availability group to which the replica belongs.
              valuemap:
                name: 'MSSQL - Yes / No'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].is_local.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_replica,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
            - uuid: ec1b71f75c4247c28d5830bd8004f0ac
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Join state'
              type: DEPENDENT
              key: 'mssql.replica.join_state["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                0 = Not joined
                1 = Joined, standalone instance
                2 = Joined, failover cluster instance
              valuemap:
                name: 'MSSQL AG Join state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].join_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_replica,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
            - uuid: ad3e6d5bf510496eb050b9a05f8341e1
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Operational state'
              type: DEPENDENT
              key: 'mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Current operational state of the replica:
                0 = Pending failover
                1 = Pending
                2 = Online
                3 = Offline
                4 = Failed
                5 = Failed, no quorum
                6 = Not local
              valuemap:
                name: 'MSSQL AG Operational state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].operational_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_replica,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
              trigger_prototypes:
                - uuid: 0192e9d5795a4d46acb8de29f710edcd
                  expression: 'last(/MSSQL by ODBC/mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=0 or last(/MSSQL by ODBC/mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=1 or last(/MSSQL by ODBC/mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=3'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is {ITEM.VALUE}'
                  priority: WARNING
                  description: 'The operational state of the replica in a given availability group is "Pending" or "Offline".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: availability
                - uuid: 3f2006b9ae114e01b442b34fec9373d3
                  expression: 'last(/MSSQL by ODBC/mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=4'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is {ITEM.VALUE}'
                  priority: AVERAGE
                  description: 'The operational state of the replica in a given availability group is "Failed".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: availability
                - uuid: 94ea79848a5048d8ae417df709b8d612
                  expression: 'last(/MSSQL by ODBC/mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=5'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is {ITEM.VALUE}'
                  priority: HIGH
                  description: 'The operational state of the replica in a given availability group is "Failed, no quorum".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: availability
            - uuid: 2a58cab2197348d997bdb69bb128414d
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Recovery health'
              type: DEPENDENT
              key: 'mssql.replica.recovery_health["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Rollup of the "database_state" column of the `sys.dm_hadr_database_replica_states` dynamic management view:
                0 = In progress. At least one joined database has a database state other than "Online" (database_state is not "0").
                1 = Online. All the joined databases have a database state of "Online" (database_state is "0").
              valuemap:
                name: 'MSSQL AG Recovery health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].recovery_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_replica,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
              trigger_prototypes:
                - uuid: 58f508b855364d769e2be977793a03c8
                  expression: 'last(/MSSQL by ODBC/mssql.replica.recovery_health["{#GROUP_NAME}_{#REPLICA_NAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} Recovery in progress'
                  priority: INFO
                  description: 'At least one joined database has a database state other than "Online".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: notice
            - uuid: 5139a4cef5ac46d2ab34cd8bda1c84ac
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Role'
              type: DEPENDENT
              key: 'mssql.replica.role["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Current Always On availability group role of a local replica or a connected remote replica:
                0 = Resolving
                1 = Primary
                2 = Secondary
              valuemap:
                name: 'MSSQL AG Role'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].role.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_replica,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
            - uuid: 5655f95df0e043acba246f65e4905b0d
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Sync health'
              type: DEPENDENT
              key: 'mssql.replica.synchronization_health["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Reflects a rollup of the database synchronization state (synchronization_state) of all joined availability databases (also known as replicas) and the availability mode of the replica (synchronous-commit or asynchronous-commit mode). The rollup will reflect the least healthy accumulated state of the databases on the replica:
                0 = Not healthy. At least one joined database is in the "Not synchronizing" state.
                1 = Partially healthy. Some replicas are not in the target synchronization state: synchronous-commit replicas should be synchronized, and asynchronous-commit replicas should be synchronizing.
                2 = Healthy. All replicas are in the target synchronization state: synchronous-commit replicas are synchronized, and asynchronous-commit replicas are synchronizing.
              valuemap:
                name: 'MSSQL AG Synchronization health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].synchronization_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_replica,"{$MSSQL.DSN}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
              trigger_prototypes:
                - uuid: f2f4d198ad2242088d867abe6fac4ecd
                  expression: 'last(/MSSQL by ODBC/mssql.replica.synchronization_health["{#GROUP_NAME}_{#REPLICA_NAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is Not healthy'
                  priority: AVERAGE
                  description: 'At least one joined database is in the "Not synchronizing" state.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: availability
                - uuid: 070af612aa7248588fc058d8f9fb9929
                  expression: 'last(/MSSQL by ODBC/mssql.replica.synchronization_health["{#GROUP_NAME}_{#REPLICA_NAME}"])=1'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is Partially healthy'
                  priority: WARNING
                  description: 'Some replicas are not in the target synchronization state: synchronous-commit replicas should be synchronized, and asynchronous-commit replicas should be synchronizing.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: availability
          trigger_prototypes:
            - uuid: 7c6afc5596e94af0979bd20d5ef542ea
              expression: 'last(/MSSQL by ODBC/mssql.replica.connected_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=0 and last(/MSSQL by ODBC/mssql.replica.role["{#GROUP_NAME}_{#REPLICA_NAME}"])=2'
              name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is disconnected'
              priority: WARNING
              description: |
                The response of an availability replica to the "Disconnected" state depends on its role:
                On the primary replica, if a secondary replica is disconnected, its secondary databases are marked as "Not synchronized" on the primary replica, which waits for the secondary to reconnect;
                On a secondary replica, upon detecting that it is disconnected, the secondary replica attempts to reconnect to the primary replica.
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: replica
                  value: '{#REPLICA_NAME}'
                - tag: scope
                  value: availability
          master_item:
            key: 'db.odbc.get[get_replica,"{$MSSQL.DSN}"]'
          lld_macro_paths:
            - lld_macro: '{#GROUP_NAME}'
              path: $.group_name
            - lld_macro: '{#REPLICA_NAME}'
              path: $.replica_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: mssql
      macros:
        - macro: '{$MSSQL.AVERAGE_WAIT_TIME.MAX}'
          value: '500'
          description: 'The maximum average wait time, in milliseconds - for the trigger expression.'
          config:
            type: TEXT
            priority: '16'
            section_name: Thresholds
            label: 'Average wait time threshold'
            description: 'Threshold of the maximum average wait time in milliseconds. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.BACKUP_DIFF.CRIT}'
          value: 6d
          description: 'The maximum of days without a differential backup - for the High trigger expression.'
          config:
            type: TEXT
            priority: '27'
            section_name: Thresholds
            label: 'Critical differential backup threshold'
            description: 'Critical threshold of the maximum days without a differential backup.'
        - macro: '{$MSSQL.BACKUP_DIFF.USED}'
          value: '1'
          description: 'The flag for checking the age of a differential backup. If set to a value other than "1", the trigger expression for the differential backup age will not fire. Can be used with context for database name.'
          config:
            type: CHECKBOX
            priority: '35'
            section_name: Other
            label: 'Monitoring of differential backup'
            description: 'Whether it is necessary to monitor of differential backup.'
            options:
              - checked: '1'
                unchecked: '0'
        - macro: '{$MSSQL.BACKUP_DIFF.WARN}'
          value: 3d
          description: 'The maximum of days without a differential backup - for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '26'
            section_name: Thresholds
            label: 'Warning differential backup threshold'
            description: 'Warning threshold of the maximum days without a differential backup.'
        - macro: '{$MSSQL.BACKUP_DURATION.WARN}'
          value: 1h
          description: 'The maximum job duration - for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '32'
            section_name: Thresholds
            label: 'Job duration threshold'
            description: 'Threshold of the maximum job duration.'
        - macro: '{$MSSQL.BACKUP_FULL.CRIT}'
          value: 10d
          description: 'The maximum of days without a full backup - for the High trigger expression.'
          config:
            type: TEXT
            priority: '29'
            section_name: Thresholds
            label: 'Critical full backup threshold'
            description: 'Critical threshold of the maximum days without a full backup.'
        - macro: '{$MSSQL.BACKUP_FULL.USED}'
          value: '1'
          description: 'The flag for checking the age of a full backup. If set to a value other than "1", the trigger expression for the full backup age will not fire. Can be used with context for database name.'
          config:
            type: CHECKBOX
            priority: '33'
            section_name: Other
            label: 'Monitoring of full backup'
            description: 'Whether it is necessary to monitor of full backup.'
            options:
              - checked: '1'
                unchecked: '0'
        - macro: '{$MSSQL.BACKUP_FULL.WARN}'
          value: 9d
          description: 'The maximum of days without a full backup - for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '28'
            section_name: Thresholds
            label: 'Warning full backup threshold'
            description: 'Warning threshold of the maximum days without a full backup.'
        - macro: '{$MSSQL.BACKUP_LOG.CRIT}'
          value: 8h
          description: 'The maximum of days without a log backup - for the High trigger expression.'
          config:
            type: TEXT
            priority: '31'
            section_name: Thresholds
            label: 'Critical log backup threshold'
            description: 'Critical threshold of the maximum days without a log backup.'
        - macro: '{$MSSQL.BACKUP_LOG.USED}'
          value: '1'
          description: 'The flag for checking the age of a log backup. If set to a value other than "1", the trigger expression for the log backup age will not fire. Can be used with context for database name.'
          config:
            type: CHECKBOX
            priority: '34'
            section_name: Other
            label: 'Monitoring of log backup'
            description: 'Whether it is necessary to monitor of log backup.'
            options:
              - checked: '1'
                unchecked: '0'
        - macro: '{$MSSQL.BACKUP_LOG.WARN}'
          value: 4h
          description: 'The maximum of days without a log backup - for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '30'
            section_name: Thresholds
            label: 'Warning log backup threshold'
            description: 'Warning threshold of the maximum days without a log backup.'
        - macro: '{$MSSQL.BUFFER_CACHE_RATIO.MIN.CRIT}'
          value: '30'
          description: 'The minimum buffer cache hit ratio, in percent - for the High trigger expression.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'Critical buffer cache hit ratio threshold'
            description: 'Critical threshold for the minimum percentage of buffer cache hit ratio. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.BUFFER_CACHE_RATIO.MIN.WARN}'
          value: '50'
          description: 'The minimum buffer cache hit ratio, in percent - for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Warning buffer cache hit ratio threshold'
            description: 'Warning threshold for the minimum percentage of buffer cache hit ratio. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.DBNAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in database discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '36'
            section_name: Filters
            label: 'Include database filter'
            description: 'Regex string to include discovered database by its name.'
        - macro: '{$MSSQL.DBNAME.NOT_MATCHES}'
          value: master|tempdb|model|msdb
          description: 'This macro is used in database discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '37'
            section_name: Filters
            label: 'Exclude database filter'
            description: 'Regex string to exclude discovered database by its name.'
        - macro: '{$MSSQL.DEADLOCKS.MAX}'
          value: '1'
          description: 'The maximum deadlocks per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '19'
            section_name: Thresholds
            label: 'Deadlocks per second threshold'
            description: 'Threshold of the maximum number of deadlocks per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.DSN}'
          description: 'System data source name.'
          config:
            type: TEXT
            priority: '1'
            label: 'MSSQL DSN'
            description: 'Data source name of the MSSQL instance.'
            required: 'YES'
        - macro: '{$MSSQL.FREE_LIST_STALLS.MAX}'
          value: '2'
          description: 'The maximum free list stalls per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'Free list stalls per second threshold'
            description: 'Threshold of the maximum number of free list stalls per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.HOST}'
          value: localhost
          description: 'The hostname or IP address of the MSSQL instance.'
          config:
            type: TEXT
            priority: '4'
            label: 'MSSQL address'
            description: 'Hostname or IP address of the MSSQL instance.'
        - macro: '{$MSSQL.JOB.MATCHES}'
          value: '.*'
          description: 'This macro is used in job discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '38'
            section_name: Filters
            label: 'Include job filter'
            description: 'Regex string to include discovered job by its name.'
        - macro: '{$MSSQL.JOB.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in job discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '39'
            section_name: Filters
            label: 'Exclude job filter'
            description: 'Regex string to exclude discovered job by its name.'
        - macro: '{$MSSQL.LAZY_WRITES.MAX}'
          value: '20'
          description: 'The maximum lazy writes per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '12'
            section_name: Thresholds
            label: 'Lazy writes per second threshold'
            description: 'Threshold of the maximum number of lazy writes per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.LOCK_REQUESTS.MAX}'
          value: '1000'
          description: 'The maximum lock requests per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '17'
            section_name: Thresholds
            label: 'Lock requests per second threshold'
            description: 'Threshold of the maximum number of lock requests per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.LOCK_TIMEOUTS.MAX}'
          value: '1'
          description: 'The maximum lock timeouts per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '18'
            section_name: Thresholds
            label: 'Lock timeouts per second threshold'
            description: 'Threshold of the maximum number of lock timeouts per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.LOG_FLUSH_WAITS.MAX}'
          value: '1'
          description: 'The maximum log flush waits per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '20'
            section_name: Thresholds
            label: 'Log flush waits per second threshold'
            description: 'Threshold for the maximum number of log flush waits per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.LOG_FLUSH_WAIT_TIME.MAX}'
          value: '1'
          description: 'The maximum log flush wait time, in milliseconds - for the trigger expression.'
          config:
            type: TEXT
            priority: '21'
            section_name: Thresholds
            label: 'Log flush wait time threshold'
            description: 'Threshold of the maximum log flush wait time in milliseconds. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PAGE_LIFE_EXPECTANCY.MIN}'
          value: '300'
          description: 'The minimum page life expectancy - for the trigger expression.'
          config:
            type: TEXT
            priority: '13'
            section_name: Thresholds
            label: 'Page life expectancy threshold'
            description: 'Threshold of the minimum page life expectancy. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PAGE_READS.MAX}'
          value: '90'
          description: 'The maximum page reads per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '14'
            section_name: Thresholds
            label: 'Page reads per second threshold'
            description: 'Threshold of the maximum number of page reads per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PAGE_WRITES.MAX}'
          value: '90'
          description: 'The maximum page writes per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '15'
            section_name: Thresholds
            label: 'Page writes per second threshold'
            description: 'Threshold of the maximum number of page writes per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PASSWORD}'
          description: 'MSSQL user password.'
          config:
            type: TEXT
            priority: '3'
            label: 'MSSQL password'
            required: 'YES'
        - macro: '{$MSSQL.PERCENT_COMPILATIONS.MAX}'
          value: '10'
          description: 'The maximum percentage of Transact-SQL compilations - for the trigger expression.'
          config:
            type: TEXT
            priority: '23'
            section_name: Thresholds
            label: 'Transact-SQL compilations threshold'
            description: 'Threshold for the maximum percentage of Transact-SQL compilations. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PERCENT_LOG_USED.MAX}'
          value: '80'
          description: 'The maximum percentage of log used - for the trigger expression.'
          config:
            type: TEXT
            priority: '22'
            section_name: Thresholds
            label: 'Log used threshold'
            description: 'Threshold for the maximum percentage of log used. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PERCENT_READAHEAD.MAX}'
          value: '20'
          description: 'The maximum percentage of pages read per second in anticipation of use - for the trigger expression.'
          config:
            type: TEXT
            priority: '25'
            section_name: Thresholds
            label: 'Threshold of pages read per second in anticipation of use'
            description: 'Threshold of the maximum percentage of pages read per second in anticipation of use. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PERCENT_RECOMPILATIONS.MAX}'
          value: '10'
          description: 'The maximum percentage of Transact-SQL recompilations - for the trigger expression.'
          config:
            type: TEXT
            priority: '24'
            section_name: Thresholds
            label: 'Transact-SQL recompilations threshold'
            description: 'Threshold for the maximum percentage of Transact-SQL recompilations. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PORT}'
          value: '1433'
          description: 'MSSQL TCP port.'
          config:
            type: TEXT
            priority: '5'
            label: 'MSSQL TCP port'
            description: 'Port of the MSSQL instance. In the range from 1 to 65535 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.QUORUM.MEMBER.DISCOVERY.NAME.MATCHES}'
          value: '.*'
          description: 'Filter to include discovered quorum member by name.'
          config:
            type: TEXT
            priority: '40'
            section_name: Filters
            label: 'Include quorum member filter'
            description: 'Regex string to include discovered quorum member by name.'
        - macro: '{$MSSQL.QUORUM.MEMBER.DISCOVERY.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discovered quorum member by name.'
          config:
            type: TEXT
            priority: '41'
            section_name: Filters
            label: 'Exclude quorum member filter'
            description: 'Regex string to exclude discovered quorum member by name.'
        - macro: '{$MSSQL.USER}'
          description: 'MSSQL username.'
          config:
            type: TEXT
            priority: '2'
            label: 'MSSQL user'
            required: 'YES'
        - macro: '{$MSSQL.WORKTABLES_FROM_CACHE_RATIO.MIN.CRIT}'
          value: '90'
          description: 'The minimum percentage of work tables from the cache ratio - for the High trigger expression.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Percentage of work tables from the cache ratio threshold'
            description: 'Threshold for the minimum percentage of work tables from the cache ratio. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.WORK_FILES.MAX}'
          value: '20'
          description: 'The maximum number of work files created per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '6'
            section_name: Thresholds
            label: 'Work files created per second threshold'
            description: 'Threshold of the maximum number of work files created per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.WORK_TABLES.MAX}'
          value: '20'
          description: 'The maximum number of work tables created per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Work files tables per second threshold'
            description: 'Threshold of the maximum number of work tables created per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
      dashboards:
        - uuid: 168d5d7b54374d8a951818ba619e0319
          name: 'MSSQL: Overview'
          pages:
            - name: Main
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Errors'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Server memory'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Waits per second'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Database pages'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graph
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Transactions'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graph
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Pages'
                    - type: STRING
                      name: reference
                      value: AAAAK
                - type: graph
                  'y': '30'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Memory grants outstanding and pending'
                    - type: STRING
                      name: reference
                      value: AAAAM
                - type: graph
                  'y': '35'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Access methods'
                    - type: STRING
                      name: reference
                      value: AAAAO
                - type: graph
                  'y': '40'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Logins per second and Logouts per second'
                    - type: STRING
                      name: reference
                      value: AAAAQ
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Locks'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Memory/cache load'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Wait times'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Cache objects'
                    - type: STRING
                      name: reference
                      value: AAAAH
                - type: graph
                  x: '36'
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Compilations'
                    - type: STRING
                      name: reference
                      value: AAAAJ
                - type: graph
                  x: '36'
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Page life expectancy'
                    - type: STRING
                      name: reference
                      value: AAAAL
                - type: graph
                  x: '36'
                  'y': '30'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Processes blocked'
                    - type: STRING
                      name: reference
                      value: AAAAN
                - type: graph
                  x: '36'
                  'y': '35'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'MSSQL: Auto-params'
                    - type: STRING
                      name: reference
                      value: AAAAP
            - name: Databases
              widgets:
                - type: graphprototype
                  width: '36'
                  height: '15'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'DB ''{#DBNAME}'': Size'
                    - type: STRING
                      name: reference
                      value: AAAAR
                    - type: INTEGER
                      name: rows
                      value: '3'
                - type: graphprototype
                  x: '36'
                  width: '36'
                  height: '15'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'MSSQL by ODBC'
                        name: 'DB ''{#DBNAME}'': Log size'
                    - type: STRING
                      name: reference
                      value: AAAAS
                    - type: INTEGER
                      name: rows
                      value: '3'
      valuemaps:
        - uuid: c66ee50a8b3f4b6788b732bb8a6b514e
          name: 'MSSQL - Yes / No'
          mappings:
            - value: '0'
              newvalue: 'No'
            - value: '1'
              newvalue: 'Yes'
        - uuid: bfbb00eb85d747dabeda2954a5d659b7
          name: 'MSSQL AG Connected state'
          mappings:
            - value: '0'
              newvalue: Disconnected
            - value: '1'
              newvalue: Connected
        - uuid: 47413c135c094cdc8b59f18a9b195a78
          name: 'MSSQL AG Join state'
          mappings:
            - value: '0'
              newvalue: 'Not joined'
            - value: '1'
              newvalue: 'Joined, standalone instance'
            - value: '2'
              newvalue: 'Joined, failover cluster instance'
        - uuid: a570f341d9a8470797aecfebd376b2b8
          name: 'MSSQL AG Operational state'
          mappings:
            - value: '0'
              newvalue: 'Pending failover'
            - value: '1'
              newvalue: Pending
            - value: '2'
              newvalue: Online
            - value: '3'
              newvalue: Offline
            - value: '4'
              newvalue: Failed
            - value: '5'
              newvalue: 'Failed, no quorum'
            - value: '6'
              newvalue: 'Replica is not local'
        - uuid: 4ec6a96ff6c64756b2f27e47972fd9f6
          name: 'MSSQL AG Recovery health'
          mappings:
            - value: '0'
              newvalue: 'In progress'
            - value: '1'
              newvalue: Online
            - value: '2'
              newvalue: 'Replica is not local'
        - uuid: 596556fba6064efb8155233371eb2950
          name: 'MSSQL AG Role'
          mappings:
            - value: '0'
              newvalue: Resolving
            - value: '1'
              newvalue: Primary
            - value: '2'
              newvalue: Secondary
        - uuid: 2ab0923b3ce14ffc9dd454114f6b15be
          name: 'MSSQL AG Synchronization health'
          mappings:
            - value: '0'
              newvalue: 'Not healthy'
            - value: '1'
              newvalue: 'Partially healthy'
            - value: '2'
              newvalue: Healthy
        - uuid: bac1a10dad134d50add5bc9550e2ebf3
          name: 'MSSQL DB state'
          mappings:
            - value: '0'
              newvalue: ONLINE
            - value: '1'
              newvalue: RESTORING
            - value: '2'
              newvalue: RECOVERING
            - value: '3'
              newvalue: RECOVERY_PENDING
            - value: '4'
              newvalue: SUSPECT
            - value: '5'
              newvalue: EMERGENCY
            - value: '6'
              newvalue: OFFLINE
            - value: '7'
              newvalue: COPYING
            - value: '10'
              newvalue: OFFLINE_SECONDARY
        - uuid: eefa6e0e6f8b4facbc12004437b7ee8f
          name: 'MSSQL Job Run Status'
          mappings:
            - value: '0'
              newvalue: Failed
            - value: '1'
              newvalue: Succeeded
            - value: '2'
              newvalue: Retry
            - value: '3'
              newvalue: Canceled
            - value: '4'
              newvalue: Running
            - value: '5'
              newvalue: Unknown
        - uuid: 09aaa82ccd6a444b80d5d3bb182fbafd
          name: 'MSSQL Mirroring Role'
          mappings:
            - value: '0'
              newvalue: 'Database is inaccessible or is not mirrored'
            - value: '1'
              newvalue: Principal
            - value: '2'
              newvalue: Mirror
        - uuid: f1c105c262c5476798a93eaa4c46fbda
          name: 'MSSQL Mirroring State'
          mappings:
            - value: '0'
              newvalue: Suspended
            - value: '1'
              newvalue: 'Disconnected from the other partner'
            - value: '2'
              newvalue: Synchronizing
            - value: '3'
              newvalue: 'Pending failover'
            - value: '4'
              newvalue: Synchronized
            - value: '5'
              newvalue: 'The partners are not synchronized. Failover is not possible now.'
            - value: '6'
              newvalue: 'The partners are synchronized. Failover is potentially possible.'
            - value: '7'
              newvalue: 'Database is inaccessible or is not mirrored'
        - uuid: 1454643e9cad46f8953f4c054509151c
          name: 'MSSQL Quorum members state'
          mappings:
            - value: '0'
              newvalue: Offline
            - value: '1'
              newvalue: Online
        - uuid: caa789916da048c691f8eef5a71a856e
          name: 'MSSQL Quorum members type'
          mappings:
            - value: '0'
              newvalue: 'WSFC node'
            - value: '1'
              newvalue: 'Disk witness'
            - value: '2'
              newvalue: 'File share witness'
            - value: '3'
              newvalue: 'Cloud Witness'
        - uuid: 23c9fede4c9a4a21854b3fc83de459a7
          name: 'MSSQL Quorum state'
          mappings:
            - value: '0'
              newvalue: 'Unknown quorum state'
            - value: '1'
              newvalue: 'Normal quorum'
            - value: '2'
              newvalue: 'Forced quorum'
        - uuid: fbf296f404ad45d5b02e3c20104b9b9e
          name: 'MSSQL Quorum type'
          mappings:
            - value: '0'
              newvalue: 'Node Majority'
            - value: '1'
              newvalue: 'Node and Disk Majority'
            - value: '2'
              newvalue: 'Node and File Share Majority'
            - value: '3'
              newvalue: 'No Majority: Disk Only'
            - value: '4'
              newvalue: 'Unknown Quorum'
            - value: '5'
              newvalue: 'Cloud Witness'
        - uuid: f59af5b534994dccaebb4afc3266520b
          name: 'MSSQL Recovery model'
          mappings:
            - value: '1'
              newvalue: FULL
            - value: '2'
              newvalue: BULK_LOGGED
            - value: '3'
              newvalue: SIMPLE
        - uuid: e70421b2c3db4ce1937791bdb432040e
          name: 'MSSQL Safety level'
          mappings:
            - value: '0'
              newvalue: 'Unknown state'
            - value: '1'
              newvalue: 'Off [asynchronous]'
            - value: '2'
              newvalue: 'Full [synchronous]'
            - value: '3'
              newvalue: 'Database is inaccessible or is not mirrored'
        - uuid: aa9de6e21d08486db04f29e10d11a94c
          name: 'MSSQL Witness state'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Connected
            - value: '2'
              newvalue: Disconnected
            - value: '3'
              newvalue: 'No witness exists'
        - uuid: 03cde96b90a641598db572a662dc2064
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: 75fc96367e8d4588ba8314145fc12d35
      template: 'MSSQL by Zabbix agent 2'
      name: 'MSSQL by Zabbix agent 2'
      description: |
        This template is designed for the effortless deployment of MSSQL monitoring by Zabbix via Zabbix agent 2 and uses a loadable plugin to run SQL queries.
        
        Setup:
        
        1. Deploy Zabbix agent 2 with the MSSQL plugin. You can use this template starting with version 7.4.0 of both Zabbix and the MSSQL plugin.
        
          For more information, see MSSQL plugin documentation: https://git.zabbix.com/projects/AP/repos/mssql/browse
        
          Important! Starting with version 7.4-1 of this template, the MSSQL plugin must be updated to a version equal to or above 7.4.0. (You can check the version of the template in its YAML file under the "vendor" section.)
        
          Loadable plugin requires installation of one of the following:
        
          - Separate package
          
          - Binary file
          
          - Compilation from sources: https://www.zabbix.com/documentation/7.4/manual/extensions/plugins/build
        
        2. Create an MSSQL user for monitoring.
        
          View Server State and View Any Definition permissions should be granted to the user.
          Grant this user read permissions to the sysjobschedules, sysjobhistory, and sysjobs tables.
        
          For more information, see MSSQL documentation:
          
          - Create a database user: https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/create-a-database-user?view=sql-server-ver16
          
          - GRANT Server Permissions: https://docs.microsoft.com/en-us/sql/t-sql/statements/grant-server-permissions-transact-sql?view=sql-server-ver16
          
          - Configure a User to Create and Manage SQL Server Agent Jobs: https://docs.microsoft.com/en-us/sql/ssms/agent/configure-a-user-to-create-and-manage-sql-server-agent-jobs?view=sql-server-ver16
        
        3. Set the user name and password in the host macros ({$MSSQL.USER} and {$MSSQL.PASSWORD}).
        
        4. Set the connection string for the MSSQL instance in the {$MSSQL.URI} macro as a URI, such as <protocol://host:port>, or specify the named session - <sessionname>.
        
        The "Service's TCP port state" item uses the {$MSSQL.HOST} and {$MSSQL.PORT} macros to check the availability of the MSSQL instance, change these if necessary. Keep in mind that if dynamic ports are used on the MSSQL server side, this check will not work correctly.
        
        Note: You can use the context macros {$MSSQL.BACKUP_FULL.USED}, {$MSSQL.BACKUP_LOG.USED}, and {$MSSQL.BACKUP_DIFF.USED} to disable backup age triggers for a certain database. If set to a value other than "1", the trigger expression for the backup age will not fire.
        
        Note: Since version 7.2.0, you can also connect to the MSSQL instance using its name. To do this, set the connection string in the {$MSSQL.URI} macro as <protocol://host/instance_name>.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        1. Create an MSSQL user for monitoring. For example, "zbx_monitor".
        
        **View Server State** and **View Any Definition** permissions should be granted to the user.
        Grant this user read permissions to the `sysjobschedules`, `sysjobhistory`, and `sysjobs` tables.
        
        For example, using T-SQL commands:
        
        ```sql
        GRANT SELECT ON OBJECT::msdb.dbo.sysjobs TO zbx_monitor;
        GRANT SELECT ON OBJECT::msdb.dbo.sysjobservers TO zbx_monitor;
        GRANT SELECT ON OBJECT::msdb.dbo.sysjobactivity TO zbx_monitor;
        GRANT EXECUTE ON OBJECT::msdb.dbo.agent_datetime TO zbx_monitor;
        ```
        
        For more information, see MSSQL documentation:
        
        [Create a database user](https://docs.microsoft.com/en-us/sql/relational-databases/security/authentication-access/create-a-database-user?view=sql-server-ver16)
        
        [GRANT Server Permissions](https://docs.microsoft.com/en-us/sql/t-sql/statements/grant-server-permissions-transact-sql?view=sql-server-ver16)
        
        [Configure a User to Create and Manage SQL Server Agent Jobs](https://docs.microsoft.com/en-us/sql/ssms/agent/configure-a-user-to-create-and-manage-sql-server-agent-jobs?view=sql-server-ver16)
        
        2. Set the username and password in the `MSSQL user` and `MSSQL password` host wizard configuration fields.
        
        3. Set the connection string for the MSSQL instance in the `MSSQL URI` host wizard configuration field as a URI, such as `<protocol://host:port>`, or specify the named session - `<sessionname>`.
        
        The `Service's TCP port state` item uses the `MSSQL address` and `MSSQL TCP port` host wizard configuration fields to check the availability of the MSSQL instance, change these if necessary. Keep in mind that if dynamic ports are used on the MSSQL server side, this check will not work correctly.
        
        Note: You can use the `Monitoring of full backup`, `Monitoring of log backup`, and `Monitoring of differential backup` host wizard configuration fields to disable backup age triggers. If set to unselected state, the trigger expression for the backup age will not fire.
        
        Note: Since version 7.2.0, you can also connect to the MSSQL instance using its name. To do this, set the connection string in the `MSSQL URI` host wizard configuration field as `<protocol://host/instance_name>`.
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Databases
      items:
        - uuid: 668f0a143b164fd5b62b1311ac798ca3
          name: 'Get Access Methods counters'
          type: DEPENDENT
          key: mssql.access_methods.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets server information about access methods.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Access Methods'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: raw
        - uuid: e48534a4fd3042ee9c2f0155230298a2
          name: 'Auto-param attempts per second'
          type: DEPENDENT
          key: mssql.autoparam_attempts_sec.rate
          value_type: FLOAT
          description: 'Number of auto-parameterization attempts per second. The total should be the sum of the failed, safe, and unsafe auto-parameterizations. Auto-parameterization occurs when an instance of SQL Server tries to parameterize a Transact-SQL request by replacing some literals with parameters so that reuse of the resulting cached execution plan across multiple similar-looking requests is possible. Note that auto-parameterizations are also known as simple parameterizations in the newer versions of SQL Server. This counter does not include forced parameterizations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Auto-Param Attempts/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: 71ade3c11bcd4f4691c5fa1c3fa6ded1
          name: 'Get availability groups'
          key: 'mssql.availability.group.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          history: '0'
          value_type: TEXT
          description: 'The item gets availability group states - name, primary and secondary health, synchronization health.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 8c5e2250dcc4405d95cc33167be33bb2
          name: 'Average latch wait time'
          type: CALCULATED
          key: mssql.average_latch_wait_time
          delay: 0;m0-59s3
          value_type: FLOAT
          units: ms
          params: |
            (last(//mssql.average_latch_wait_time_raw) - last(//mssql.average_latch_wait_time_raw,#2)) /
            (last(//mssql.average_latch_wait_time_base) - last(//mssql.average_latch_wait_time_base,#2) +
            (last(//mssql.average_latch_wait_time_base) - last(//mssql.average_latch_wait_time_base,#2)=0))
          description: 'Average latch wait time (in milliseconds) for latch requests that had to wait.'
          tags:
            - tag: component
              value: wait-time
        - uuid: 394d622b256945289ed9ca88999e024d
          name: 'Average latch wait time base'
          type: DEPENDENT
          key: mssql.average_latch_wait_time_base
          description: 'For internal use only.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Average Latch Wait Time Base'')].cntr_value.first()'
          master_item:
            key: mssql.latches_info.raw
          tags:
            - tag: component
              value: wait-time
        - uuid: fe80511b840544da86ef3dd1b34bfce2
          name: 'Average latch wait time raw'
          type: DEPENDENT
          key: mssql.average_latch_wait_time_raw
          units: ms
          description: 'Average latch wait time (in milliseconds) for latch requests that had to wait.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Average Latch Wait Time (ms)'')].cntr_value.first()'
          master_item:
            key: mssql.latches_info.raw
          tags:
            - tag: component
              value: wait-time
        - uuid: 3ba031d33d9147f786ee6fb6fddafaed
          name: 'Total average wait time'
          type: CALCULATED
          key: mssql.average_wait_time
          delay: 0;m0-59s3
          value_type: FLOAT
          units: ms
          params: |
            (last(//mssql.average_wait_time_raw) - last(//mssql.average_wait_time_raw,#2)) /
            (last(//mssql.average_wait_time_base) - last(//mssql.average_wait_time_base,#2) +
            (last(//mssql.average_wait_time_base) - last(//mssql.average_wait_time_base,#2)=0))
          description: 'The average wait time, in milliseconds, for each lock request that had to wait.'
          tags:
            - tag: component
              value: wait-time
          triggers:
            - uuid: 7d284dc23d4649c79bf67e13f1edc83b
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.average_wait_time,5m)>{$MSSQL.AVERAGE_WAIT_TIME.MAX}'
              name: 'MSSQL: Total average wait time for locks is high'
              event_name: 'MSSQL: Total average wait time for locks is high (over {$MSSQL.AVERAGE_WAIT_TIME.MAX}ms for 5m)'
              priority: WARNING
              description: 'An average wait time longer than 500 ms may indicate excessive blocking. This value should generally correlate to "Lock Waits/sec" and move up or down with it accordingly.'
              tags:
                - tag: scope
                  value: performance
        - uuid: fc14601c16314459bc8277ebd244997d
          name: 'Total average wait time base'
          type: DEPENDENT
          key: mssql.average_wait_time_base
          description: 'For internal use only.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Average Wait Time Base'')].cntr_value.first()'
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: wait-time
        - uuid: 5fa855e501dc42e68d8a06e435c08024
          name: 'Total average wait time raw'
          type: DEPENDENT
          key: mssql.average_wait_time_raw
          units: ms
          description: 'Average amount of wait time (in milliseconds) for each lock request that resulted in a wait. Information for all locks.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Average Wait Time (ms)'')].cntr_value.first()'
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: wait-time
        - uuid: b6c19fe6e67f4686a23455211fb2c076
          name: 'Batch requests per second'
          type: DEPENDENT
          key: mssql.batch_requests_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Number of Transact-SQL command batches received per second. This statistic is affected by all constraints (such as I/O, number of users, cache size, complexity of requests, and so on). High batch requests mean good throughput.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Batch Requests/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: e2581ae0fd6d4cc18728b7301cb22730
          name: 'Buffer cache hit ratio'
          type: DEPENDENT
          key: mssql.buffer_cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: 'Indicates the percentage of pages found in the buffer cache without having to read from the disk. The ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses. After a long period of time, the ratio changes very little. Since reading from the cache is much less expensive than reading from the disk, a higher value is preferred for this item. To increase the buffer cache hit ratio, consider increasing the amount of memory available to MSSQL Server or using the buffer pool extension feature.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''BufferCacheHitRatio'')].cntr_value.first()'
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: cache
          triggers:
            - uuid: 9ee2397e2560447eb01d4d50cde5fa9d
              expression: 'max(/MSSQL by Zabbix agent 2/mssql.buffer_cache_hit_ratio,5m)<{$MSSQL.BUFFER_CACHE_RATIO.MIN.CRIT}'
              name: 'MSSQL: Percentage of the buffer cache efficiency is low'
              event_name: 'MSSQL: Percentage of the buffer cache efficiency is low (below {$MSSQL.BUFFER_CACHE_RATIO.MIN.CRIT}% for 5m)'
              priority: HIGH
              description: 'Too low buffer cache hit ratio.'
              tags:
                - tag: scope
                  value: performance
            - uuid: c22ac1cbc5224eb98fde9f87c52a3724
              expression: 'max(/MSSQL by Zabbix agent 2/mssql.buffer_cache_hit_ratio,5m)<{$MSSQL.BUFFER_CACHE_RATIO.MIN.WARN}'
              name: 'MSSQL: Percentage of the buffer cache efficiency is low'
              event_name: 'MSSQL: Percentage of the buffer cache efficiency is low (below {$MSSQL.BUFFER_CACHE_RATIO.MIN.WARN}% for 5m)'
              priority: WARNING
              description: 'Low buffer cache hit ratio.'
              dependencies:
                - name: 'MSSQL: Percentage of the buffer cache efficiency is low'
                  expression: 'max(/MSSQL by Zabbix agent 2/mssql.buffer_cache_hit_ratio,5m)<{$MSSQL.BUFFER_CACHE_RATIO.MIN.CRIT}'
              tags:
                - tag: scope
                  value: performance
        - uuid: 2e0810566767476db6cd0ca4eccb9e99
          name: 'Get Buffer Manager counters'
          type: DEPENDENT
          key: mssql.buffer_manager.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets server information about the buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Buffer Manager'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: raw
        - uuid: ca959c973e8a4a549c0c33c85dce3598
          name: 'Cache hit ratio'
          type: DEPENDENT
          key: mssql.cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: 'Ratio between cache hits and lookups.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''CacheHitRatio'')].cntr_value.first()'
          master_item:
            key: mssql.cache_info.raw
          tags:
            - tag: component
              value: cache
        - uuid: 9925ceb7e021480598aab2bfba74370d
          name: 'Get Cache counters'
          type: DEPENDENT
          key: mssql.cache_info.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets server information about cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Plan Cache'' && @.instance_name==''_Total'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 913fa728180d4a73a093a2ee05454081
          name: 'Cache objects in use'
          type: DEPENDENT
          key: mssql.cache_objects_in_use
          description: 'Number of cache objects in use.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Cache Objects in use'')].cntr_value.first()'
          master_item:
            key: mssql.cache_info.raw
          tags:
            - tag: component
              value: cache
        - uuid: 4dbb2d972bcc42f19aaa537a0d0431e9
          name: 'Cache object counts'
          type: DEPENDENT
          key: mssql.cache_object_counts
          description: 'Number of cache objects in the cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Cache Object Counts'')].cntr_value.first()'
          master_item:
            key: mssql.cache_info.raw
          tags:
            - tag: component
              value: cache
        - uuid: 952940ebb15942b3ac7d4b96c816a7c3
          name: 'Cache pages'
          type: DEPENDENT
          key: mssql.cache_pages
          description: 'Number of 8-kilobyte (KB) pages used by cache objects.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Cache Pages'')].cntr_value.first()'
          master_item:
            key: mssql.cache_info.raw
          tags:
            - tag: component
              value: cache
            - tag: component
              value: page
        - uuid: 14bba7081bd84521994b2a28d1af422d
          name: 'Checkpoint pages per second'
          type: DEPENDENT
          key: mssql.checkpoint_pages_sec.rate
          value_type: FLOAT
          description: 'Indicates the number of pages flushed to the disk per second by a checkpoint or other operation which required all dirty pages to be flushed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Checkpoint pages/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
            - tag: component
              value: performance
        - uuid: f74a2bc9da424fc0ad288ddce6a4f6fa
          name: 'Database pages'
          type: DEPENDENT
          key: mssql.database_pages
          description: 'Indicates the number of pages in the buffer pool with database content.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Database pages'')].cntr_value.first()'
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
        - uuid: d124c9d4a3724e32a37895ad1cbc036b
          name: 'Total data file size'
          type: DEPENDENT
          key: mssql.data_files_size
          units: B
          description: 'Total size of all data files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Data File(s) Size (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: mssql.db_info.raw
          tags:
            - tag: component
              value: application
        - uuid: 6c942840048b463e9439f327adceb767
          name: 'Get database'
          key: 'mssql.db.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          delay: 1h
          history: '0'
          value_type: TEXT
          description: 'Getting databases - database name and recovery model.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 7ee97938f31d4983b3c216684089c23f
          name: 'Get DB counters'
          type: DEPENDENT
          key: mssql.db_info.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets summary information about databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Databases'' && @.instance_name==''_Total'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: raw
        - uuid: b82b979548824464a204d49a9c760c99
          name: 'Total errors per second'
          type: DEPENDENT
          key: mssql.errors_sec.rate
          value_type: FLOAT
          description: 'Number of errors per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Errors/sec'' && @.instance_name==''_Total'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_errors.raw
          tags:
            - tag: component
              value: error
            - tag: component
              value: performance
        - uuid: 152cf9cbf35f475bb242ddcb58e23c35
          name: 'Failed auto-params per second'
          type: DEPENDENT
          key: mssql.failed_autoparams_sec.rate
          value_type: FLOAT
          description: 'Number of failed auto-parameterization attempts per second. This number should be small. Note that auto-parameterizations are also known as simple parameterizations in the newer versions of SQL Server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Failed Auto-Params/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: e7c66d2857034bfcbef7af94673ea66f
          name: 'Forwarded records per second'
          type: DEPENDENT
          key: mssql.forwarded_records_sec.rate
          value_type: FLOAT
          description: 'Number of records per second fetched through forwarded record pointers.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Forwarded Records/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: performance
        - uuid: 7d688d051647440595e42bd798ce78dc
          name: 'Free list stalls per second'
          type: DEPENDENT
          key: mssql.free_list_stalls_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Indicates the number of requests per second that had to wait for a free page.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Free list stalls/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: performance
          triggers:
            - uuid: 5cf3182a47694569b9d75822404b77f7
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.free_list_stalls_sec.rate,5m)>{$MSSQL.FREE_LIST_STALLS.MAX}'
              name: 'MSSQL: Number of rps waiting for a free page is high'
              event_name: 'MSSQL: Number of rps waiting for a free page is high (over {$MSSQL.FREE_LIST_STALLS.MAX} for 5m)'
              priority: WARNING
              description: 'Some requests have to wait for a free page.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 5e8ccbe07c254c2086a58aafe1aa2fdf
          name: 'Full scans per second'
          type: DEPENDENT
          key: mssql.full_scans_sec.rate
          value_type: FLOAT
          description: 'Number of unrestricted full scans per second. These can be either base-table or full-index scans. Values greater than 1 or 2 indicate that there are table / index page scans. If that is combined with high CPU, this counter requires further investigation, otherwise, if the full scans are on small tables, it can be ignored.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Full Scans/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: performance
        - uuid: 055399281d2b4e7a90ae1fb4b181a0b2
          name: 'Get General Statistics counters'
          type: DEPENDENT
          key: mssql.general_statistics.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets general statistics information.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*General Statistics'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 5aa885322d4d4f2d9b55d8f2d65f55b0
          name: 'Granted Workspace Memory'
          type: DEPENDENT
          key: mssql.granted_workspace_memory
          units: B
          description: 'Specifies the total amount of memory currently granted to executing processes, such as hash, sort, bulk copy, and index creation operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Granted Workspace Memory (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: 65a2e35bc66e45a08690faf08733c5fb
          name: 'Index searches per second'
          type: DEPENDENT
          key: mssql.index_searches_sec.rate
          value_type: FLOAT
          description: 'Number of index searches per second. These are used to start a range scan, reposition a range scan, revalidate a scan point, fetch a single index record, and search down the index to locate where to insert a new row.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Index Searches/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: performance
        - uuid: 5439b52bd72e4204876d0c3716eb0a23
          name: 'Errors per second (Info errors)'
          type: DEPENDENT
          key: mssql.info_errors_sec.rate
          value_type: FLOAT
          description: 'Number of errors per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Errors/sec'' && @.instance_name==''Info Errors'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_errors.raw
          tags:
            - tag: component
              value: error
            - tag: component
              value: performance
        - uuid: e36f8695b4f74178a19bb88afad586b8
          name: 'Get job status'
          key: 'mssql.job.status.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          delay: 10m
          history: '0'
          value_type: TEXT
          description: 'The item gets the SQL agent job status.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: c43a0e1c2adf45cf8809e9a361ec190e
          name: 'Errors per second (Kill connection errors)'
          type: DEPENDENT
          key: mssql.kill_connection_errors_sec.rate
          value_type: FLOAT
          description: 'Number of errors per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Errors/sec'' && @.instance_name==''Kill Connection Errors'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_errors.raw
          tags:
            - tag: component
              value: error
            - tag: component
              value: performance
        - uuid: a394835aeddd46a18327f25747e3564d
          name: 'Get last backup'
          key: 'mssql.last.backup.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          delay: 10m
          history: '0'
          value_type: TEXT
          description: 'The item gets information about backup processes.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 2bd7c7ec217b4f62b7d94a42e9324f51
          name: 'Get Latches counters'
          type: DEPENDENT
          key: mssql.latches_info.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets server information about latches.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Latches'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 2daa0932d2a9491f9b262c06def40ccc
          name: 'Latch waits per second'
          type: DEPENDENT
          key: mssql.latch_waits_sec.rate
          value_type: FLOAT
          units: rps
          description: 'The number of latch requests that could not be granted immediately. Latches are lightweight means of holding a very transient server resource, such as an address in memory.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Latch Waits/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.latches_info.raw
          tags:
            - tag: component
              value: performance
            - tag: component
              value: wait-time
        - uuid: d5710a51fb474d14b7d7716781b76c58
          name: 'Lazy writes per second'
          type: DEPENDENT
          key: mssql.lazy_writes_sec.rate
          value_type: FLOAT
          description: 'Indicates the number of buffers written per second by the buffer manager''s lazy writer. The lazy writer is a system process that flushes out batches of dirty, aged buffers (buffers that contain changes that must be written back to the disk before the buffer can be reused for a different page) and makes them available to user processes. The lazy writer eliminates the need to perform frequent checkpoints in order to create available buffers.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Lazy writes/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: performance
          triggers:
            - uuid: 96698537fee846199197a25beecaafca
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.lazy_writes_sec.rate,5m)>{$MSSQL.LAZY_WRITES.MAX}'
              name: 'MSSQL: Number of buffers written per second by the lazy writer is high'
              event_name: 'MSSQL: Number of buffers written per second by the lazy writer is high (over {$MSSQL.LAZY_WRITES.MAX} for 5m)'
              priority: WARNING
              description: 'The number of buffers written per second by the buffer manager''s lazy writer exceeds the threshold.'
              tags:
                - tag: scope
                  value: performance
        - uuid: f049c16678ad4daa83e55ab6c3a99fbc
          name: 'Get local DB'
          key: 'mssql.local.db.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          history: '0'
          value_type: TEXT
          description: 'Getting the states of the local availability database.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 46040926001f46c685c160820194a969
          name: 'Get Locks counters'
          type: DEPENDENT
          key: mssql.locks_info.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets server information about locks.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Locks'' && @.instance_name==''_Total'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: raw
        - uuid: d8adec0bd76a4e1881b8b7e0ba44c7a1
          name: 'Total lock requests per second'
          type: DEPENDENT
          key: mssql.lock_requests_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Number of new locks and lock conversions per second requested from the lock manager.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Lock Requests/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: lock
            - tag: component
              value: performance
          triggers:
            - uuid: 19137e1b06fe4f1eaf5e76c5ae47d29d
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.lock_requests_sec.rate,5m)>{$MSSQL.LOCK_REQUESTS.MAX}'
              name: 'MSSQL: Total number of locks per second is high'
              event_name: 'MSSQL: Total number of locks per second is high (over {$MSSQL.LOCK_REQUESTS.MAX} for 5m)'
              priority: WARNING
              description: 'Number of new locks and lock conversions per second requested from the lock manager is high.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 3077e748f89844e0b666a82c26051399
          name: 'Total lock requests per second that timed out'
          type: DEPENDENT
          key: mssql.lock_timeouts_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Number of timed out lock requests per second, including requests for NOWAIT locks.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Lock Timeouts/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: lock
            - tag: component
              value: performance
          triggers:
            - uuid: a7313fad35804feeaddf544acb2a0d26
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.lock_timeouts_sec.rate,5m)>{$MSSQL.LOCK_TIMEOUTS.MAX}'
              name: 'MSSQL: Total lock requests per second that timed out is high'
              event_name: 'MSSQL: Total lock requests per second that timed out is high (over {$MSSQL.LOCK_TIMEOUTS.MAX} for 5m)'
              priority: WARNING
              description: 'The total number of timed out lock requests per second, including requests for NOWAIT locks, is high.'
              tags:
                - tag: scope
                  value: performance
        - uuid: bcb606f27714414a92347a45e6bc8d31
          name: 'Total lock requests per second that required waiting'
          type: DEPENDENT
          key: mssql.lock_waits_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Number of lock requests per second that required the caller to wait.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Lock Waits/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: lock
            - tag: component
              value: performance
          triggers:
            - uuid: c4fb968a66784746a11feee64a8f98e8
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.lock_waits_sec.rate,5m)>0'
              name: 'MSSQL: Some blocking is occurring for 5m'
              priority: AVERAGE
              description: 'Values greater than zero indicate at least some blocking is occurring, while a value of zero can quickly eliminate blocking as a potential root-cause problem.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 706b5931a7d24e2190d071c1088ba469
          name: 'Lock wait time'
          type: DEPENDENT
          key: mssql.lock_wait_time
          value_type: FLOAT
          units: ms
          description: 'Average of total wait time (in milliseconds) for locks in the last second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Lock Wait Time (ms)'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: lock
        - uuid: 343c44bfdd154e99879fbecb4e703dab
          name: 'Logins per second'
          type: DEPENDENT
          key: mssql.logins_sec.rate
          value_type: FLOAT
          description: 'Total number of logins started per second. This does not include pooled connections. Any value over 2 may indicate insufficient connection pooling.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Logins/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.general_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: da069a96cc3c410db1c053d3de2a6508
          name: 'Logouts per second'
          type: DEPENDENT
          key: mssql.logouts_sec.rate
          value_type: FLOAT
          description: 'Total number of logout operations started per second. Any value over 2 may indicate insufficient connection pooling.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Logouts/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.general_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: e00f3549800a477ba77a8635a27d849b
          name: 'Total log file size'
          type: DEPENDENT
          key: mssql.log_files_size
          units: B
          description: 'Total size of all the transaction log files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Log File(s) Size (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: mssql.db_info.raw
          tags:
            - tag: component
              value: log
        - uuid: fb2125c36295434a8821462b5c86fbee
          name: 'Total log file used size'
          type: DEPENDENT
          key: mssql.log_files_used_size
          units: B
          description: 'The cumulative size of all the log files in the database.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Log File(s) Used Size (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: mssql.db_info.raw
          tags:
            - tag: component
              value: log
        - uuid: 462eecc28a3f44ef831fc76d3a0a278b
          name: 'Maximum workspace memory'
          type: DEPENDENT
          key: mssql.maximum_workspace_memory
          units: B
          description: 'Indicates the maximum amount of memory available for executing processes, such as hash, sort, bulk copy, and index creation operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Maximum Workspace Memory (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: 08919bb644c746c7a51fcc43d3581309
          name: 'Memory grants outstanding'
          type: DEPENDENT
          key: mssql.memory_grants_outstanding
          description: 'Specifies the total number of processes that have successfully acquired a workspace memory grant.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Memory Grants Outstanding'')].cntr_value.first()'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: f790245e08654eddb5cceff6405e68e2
          name: 'Memory grants pending'
          type: DEPENDENT
          key: mssql.memory_grants_pending
          description: 'Specifies the total number of processes waiting for a workspace memory grant.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Memory Grants Pending'')].cntr_value.first()'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: 4114e184cecd4040a26d9156ac11b6d2
          name: 'Get Memory counters'
          type: DEPENDENT
          key: mssql.mem_manager.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets memory information.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Memory Manager'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: raw
        - uuid: fb51801472fc4ca7beed49c2586ba1cb
          name: 'Get DB mirroring'
          key: 'mssql.mirroring.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          history: '0'
          value_type: TEXT
          description: 'Getting DB mirroring.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 8730198507594f4aa38d45bf00e65a38
          name: 'Get non-local DB'
          key: 'mssql.nonlocal.db.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          history: '0'
          value_type: TEXT
          description: 'Getting the non-local availability database.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 0e8935dc71584982b20ff2dbe42b31a4
          name: 'Total lock requests per second that have deadlocks'
          type: DEPENDENT
          key: mssql.number_deadlocks_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Number of lock requests per second that resulted in a deadlock.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Number of Deadlocks/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.locks_info.raw
          tags:
            - tag: component
              value: deadlock
            - tag: component
              value: performance
          triggers:
            - uuid: f0b039f08b694db1bbafe6b3d8d4e9ab
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.number_deadlocks_sec.rate,5m)>{$MSSQL.DEADLOCKS.MAX}'
              name: 'MSSQL: Number of deadlocks is high'
              event_name: 'MSSQL: Number of deadlocks is high (over {$MSSQL.DEADLOCKS.MAX} for 5m)'
              priority: AVERAGE
              description: 'Too many deadlocks are occurring currently.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 6e8968403b9e4abfbc5ec0a4c990636c
          name: 'Errors per second (DB offline errors)'
          type: DEPENDENT
          key: mssql.offline_errors_sec.rate
          value_type: FLOAT
          description: 'Number of errors per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Errors/sec'' && @.instance_name==''DB Offline Errors'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_errors.raw
          tags:
            - tag: component
              value: error
            - tag: component
              value: performance
        - uuid: 0b53d7e1a0174db2b6ebc1c47ac92d9e
          name: 'Page life expectancy'
          type: DEPENDENT
          key: mssql.page_life_expectancy
          value_type: FLOAT
          units: s
          description: 'Indicates the number of seconds a page will stay in the buffer pool without references.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Page life expectancy'')].cntr_value.first()'
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
          triggers:
            - uuid: e47d0eeac246490cbeedb8ba1cf77e94
              expression: 'max(/MSSQL by Zabbix agent 2/mssql.page_life_expectancy,15m)<{$MSSQL.PAGE_LIFE_EXPECTANCY.MIN}'
              name: 'MSSQL: Page life expectancy is low'
              event_name: 'MSSQL: Page life expectancy is low (less {$MSSQL.PAGE_LIFE_EXPECTANCY.MIN}min for 15m)'
              priority: HIGH
              description: 'The page stays in the buffer pool without references for less time than the threshold value.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 97fb6c5dd7de48879f378ac464c37f48
          name: 'Page lookups per second'
          type: DEPENDENT
          key: mssql.page_lookups_sec.rate
          value_type: FLOAT
          units: rps
          description: 'Indicates the number of requests per second to find a page in the buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Page lookups/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: performance
        - uuid: 936ded2166da48a8acc3c94262b0bbac
          name: 'Page reads per second'
          type: DEPENDENT
          key: mssql.page_reads_sec.rate
          value_type: FLOAT
          description: 'Indicates the number of physical database page reads that are issued per second. This statistic displays the total number of physical page reads across all databases. As physical I/O is expensive, you may be able to minimize the cost either by using a larger data cache, intelligent indexes, and more efficient queries, or by changing the database design.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Page reads/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
            - tag: component
              value: performance
          triggers:
            - uuid: 5050b7c4e5a4445d9c4aae031b01115b
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.page_reads_sec.rate,5m)>{$MSSQL.PAGE_READS.MAX}'
              name: 'MSSQL: Number of physical database page reads per second is high'
              event_name: 'MSSQL: Number of physical database page reads per second is high (over {$MSSQL.PAGE_READS.MAX} for 5m)'
              priority: WARNING
              description: 'The physical database page reads are issued too frequently.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 7e39012b0bc640689d3b295fc8f2abc6
          name: 'Page splits per second'
          type: DEPENDENT
          key: mssql.page_splits_sec.rate
          value_type: FLOAT
          description: 'Number of page splits per second that occur as a result of overflowing index pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Page Splits/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: page
            - tag: component
              value: performance
        - uuid: 2be68cb7cfe441339af164b3b4ce9c90
          name: 'Page writes per second'
          type: DEPENDENT
          key: mssql.page_writes_sec.rate
          value_type: FLOAT
          description: 'Indicates the number of physical database page writes that are issued per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Page writes/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
            - tag: component
              value: performance
          triggers:
            - uuid: 48e32bec13d34ad88db7c9cc98d86a3b
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.page_writes_sec.rate,5m)>{$MSSQL.PAGE_WRITES.MAX}'
              name: 'MSSQL: Number of physical database page writes per second is high'
              event_name: 'MSSQL: Number of physical database page writes per second is high (over {$MSSQL.PAGE_WRITES.MAX} for 5m)'
              priority: WARNING
              description: 'The physical database page writes are issued too frequently.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 2064cd9f8e7646fa8fb329ca287fedd2
          name: 'Percent of ad hoc queries running'
          type: CALCULATED
          key: mssql.percent_of_adhoc_queries
          delay: 0;m0-59s3
          value_type: FLOAT
          units: '%'
          params: |
            last(//mssql.sql_compilations_sec.rate) * 100 /
            (last(//mssql.batch_requests_sec.rate) + (last(//mssql.batch_requests_sec.rate)=0))
          description: 'The ratio of SQL compilations per second to batch requests per second, in percent.'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: cf0649863fe5421aa1dc279d1ca7e360
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.percent_of_adhoc_queries,15m) > {$MSSQL.PERCENT_COMPILATIONS.MAX}'
              name: 'MSSQL: Percent of ad hoc queries running is high'
              event_name: 'MSSQL: Percent of ad hoc queries running is over {$MSSQL.PERCENT_COMPILATIONS.MAX}% for 15m'
              priority: WARNING
              description: 'The lower this value is, the better. High values often indicate excessive ad hoc querying and should be as low as possible. If excessive ad hoc querying is happening, try rewriting the queries as procedures or invoke the queries using `sp_executeSQL`. When rewriting isn''t possible, consider using a plan guide or setting the database to parameterization forced mode.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 98b0754f231c4160bcd2daafeef64fe0
          name: 'Percent of Recompiled Transact-SQL Objects'
          type: CALCULATED
          key: mssql.percent_recompilations_to_compilations
          delay: 0;m0-59s3
          value_type: FLOAT
          units: '%'
          params: |
            last(//mssql.sql_recompilations_sec.rate) * 100 /
            (last(//mssql.sql_compilations_sec.rate) + (last(//mssql.sql_compilations_sec.rate)=0))
          description: 'The ratio of SQL re-compilations per second to SQL compilations per second, in percent.'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 1218fe12f4d542d99d997ede6cc30813
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.percent_recompilations_to_compilations,15m) > {$MSSQL.PERCENT_RECOMPILATIONS.MAX}'
              name: 'MSSQL: Percent of times statement recompiles is high'
              event_name: 'MSSQL: Percent of times statement recompiles is over {$MSSQL.PERCENT_RECOMPILATIONS.MAX}% for 15m'
              priority: WARNING
              description: 'This number should be at or near zero, since recompiles can cause deadlocks and exclusive compile locks. This counter''s value should follow in proportion to "Batch Requests/sec" and "SQL Compilations/sec".'
              tags:
                - tag: scope
                  value: performance
        - uuid: 2128f1e7d0fa46e2bdb8b06f5c07c436
          name: 'Get performance counters'
          key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          delay: 0;m0-59
          history: '0'
          value_type: TEXT
          description: 'The item gets server global status information.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 9b769f48534c4e6cb9bb2cd4079bd808
          name: 'Number of blocked processes'
          type: DEPENDENT
          key: mssql.processes_blocked
          description: 'Number of currently blocked processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Processes blocked'')].cntr_value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: mssql.general_statistics.raw
          tags:
            - tag: component
              value: application
        - uuid: 432178b4071e46758c421f6d9b75f4cd
          name: 'Get quorum'
          key: 'mssql.quorum.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          history: '0'
          value_type: TEXT
          description: 'Getting quorum - cluster name, type, and state.'
          timeout: 10s
          tags:
            - tag: component
              value: raw
        - uuid: 7343a6e34956475db3e79f7cfa905baa
          name: 'Get quorum member'
          key: 'mssql.quorum.member.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          history: '0'
          value_type: TEXT
          description: 'Getting quorum members - member name, type, state, and number of quorum votes.'
          timeout: 10s
          tags:
            - tag: component
              value: raw
        - uuid: 18b09445472c46be81281c0cb55297ea
          name: 'Read-ahead pages per second'
          type: DEPENDENT
          key: mssql.readahead_pages_sec.rate
          value_type: FLOAT
          description: 'Indicates the number of pages read per second in anticipation of use.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Readahead pages/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
            - tag: component
              value: performance
        - uuid: 77deceae02df4e2280f42ae7b7b16f76
          name: 'Get replica'
          key: 'mssql.replica.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          history: '0'
          value_type: TEXT
          description: 'Getting the database replica.'
          timeout: 30s
          tags:
            - tag: component
              value: raw
        - uuid: 7c5778b466fe488a9c7571a0b0b35597
          name: 'Safe auto-params per second'
          type: DEPENDENT
          key: mssql.safe_autoparams_sec.rate
          value_type: FLOAT
          description: 'Number of safe auto-parameterization attempts per second. Safe refers to a determination that a cached execution plan can be shared between different similar-looking Transact-SQL statements. SQL Server makes many auto-parameterization attempts, some of which turn out to be safe and others fail. Note that auto-parameterizations are also known as simple parameterizations in the newer versions of SQL Server. This does not include forced parameterizations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Safe Auto-Params/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: 5dda9c1a17fa43ada4a6857e62148f1a
          name: 'Full scans to Index searches ratio'
          type: CALCULATED
          key: mssql.scan_to_search
          delay: 0;m0-59s3
          value_type: FLOAT
          params: 'last(//mssql.full_scans_sec.rate) / (last(//mssql.index_searches_sec.rate) + (last(//mssql.index_searches_sec.rate)=0))'
          description: 'The ratio of full scans per second to index searches per second. The threshold recommendation is strictly for OLTP workloads.'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 378cdaf994ea4167b7727996357d7564
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.scan_to_search,15m) > 0.001'
              name: 'MSSQL: Number of index and table scans exceeds index searches in the last 15m'
              priority: WARNING
              description: 'Index searches are preferable to index and table scans. For OLTP applications, optimize for more index searches and less scans (preferably, 1 full scan for every 1000 index searches). Index and table scans are expensive I/O operations.'
              tags:
                - tag: scope
                  value: performance
        - uuid: f02b411d44784721a4fb4e032f094867
          name: 'SQL compilations per second'
          type: DEPENDENT
          key: mssql.sql_compilations_sec.rate
          value_type: FLOAT
          description: 'Number of SQL compilations per second. Indicates the number of times the compile code path is entered. Includes runs caused by statement-level recompilations in SQL Server. After SQL Server user activity is stable, this value reaches a steady state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''SQL Compilations/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: 60c2c827c40a4d09b0b41cd7004cb0b0
          name: 'Get SQL Errors counters'
          type: DEPENDENT
          key: mssql.sql_errors.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets SQL error information.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*SQL Errors'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 515fe1b64f82415fbdfd118358bdcc2d
          name: 'SQL re-compilations per second'
          type: DEPENDENT
          key: mssql.sql_recompilations_sec.rate
          value_type: FLOAT
          description: 'Number of statement recompiles per second. Counts the number of times statement recompiles are triggered. Generally, you want the recompiles to be low.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''SQL Re-Compilations/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: 8c18cf97c2dc4e94a9b889c72d76cdde
          name: 'Get SQL Statistics counters'
          type: DEPENDENT
          key: mssql.sql_statistics.raw
          history: '0'
          value_type: TEXT
          description: 'The item gets SQL statistics information.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*SQL Statistics'')]'
              error_handler: DISCARD_VALUE
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 78b85902a71b47b1845bb55a797e8800
          name: 'Table lock escalations per second'
          type: DEPENDENT
          key: mssql.table_lock_escalations.rate
          value_type: FLOAT
          description: 'Number of times locks on a table were escalated to the TABLE or HoBT granularity.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Table Lock Escalations/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: lock
            - tag: component
              value: performance
        - uuid: 29b91e97aa5f4efcafa38d59568c16ec
          name: 'Target pages'
          type: DEPENDENT
          key: mssql.target_pages
          description: 'The optimal number of pages in the buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Target pages'')].cntr_value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: mssql.buffer_manager.raw
          tags:
            - tag: component
              value: page
        - uuid: 06de7547c13c4e25af22c14fc7af84bd
          name: 'Target server memory'
          type: DEPENDENT
          key: mssql.target_server_memory
          units: B
          description: 'Indicates the ideal amount of memory the server can consume.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Target Server Memory (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: 304dd414b91c450db0594bd7135e340b
          name: 'Total latch wait time'
          type: DEPENDENT
          key: mssql.total_latch_wait_time
          value_type: FLOAT
          units: ms
          description: 'Total latch wait time (in milliseconds) for latch requests in the last second. This value should stay stable compared to the number of latch waits per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Total Latch Wait Time (ms)'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.latches_info.raw
          tags:
            - tag: component
              value: wait-time
        - uuid: a1dd82b237304bf39d9e34d6ff7d76a2
          name: 'Total server memory'
          type: DEPENDENT
          key: mssql.total_server_memory
          units: B
          description: 'Specifies the amount of memory the server has committed using the memory manager.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Total Server Memory (KB)'')].cntr_value.first()'
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: mssql.mem_manager.raw
          tags:
            - tag: component
              value: memory
        - uuid: f7c8f1bbf68c4f43b0e263d45022346e
          name: 'Total transactions number'
          type: DEPENDENT
          key: mssql.transactions
          description: 'The number of currently active transactions of all types.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.object_name=~''.*Transactions'' && @.counter_name==''Transactions'')].cntr_value.first()'
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: transaction
        - uuid: c23c93f8492946ba9932bf8c8a7a306e
          name: 'Total transactions per second'
          type: DEPENDENT
          key: mssql.transactions_sec.rate
          value_type: FLOAT
          description: 'Total number of transactions started for all databases per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Transactions/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.db_info.raw
          tags:
            - tag: component
              value: performance
            - tag: component
              value: transaction
        - uuid: b2805c08cc28424ca8fca0ab51ace519
          name: 'Unsafe auto-params per second'
          type: DEPENDENT
          key: mssql.unsafe_autoparams_sec.rate
          value_type: FLOAT
          description: 'Number of unsafe auto-parameterization attempts per second. For example, the query has some characteristics that prevent the cached plan from being shared. These are designated as unsafe. This does not count the number of forced parameterizations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Unsafe Auto-Params/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_statistics.raw
          tags:
            - tag: component
              value: performance
        - uuid: f4b8d9b10b4c40f6a38c03729025f618
          name: Uptime
          type: DEPENDENT
          key: mssql.uptime
          trends: '0'
          units: uptime
          description: 'MSSQL Server uptime in the format "N days, hh:mm:ss".'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Uptime'')].cntr_value.first()'
          master_item:
            key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: b64d08b9212645cd8bab9e35a8e29942
              expression: 'nodata(/MSSQL by Zabbix agent 2/mssql.uptime,30m)=1'
              name: 'MSSQL: Failed to fetch info data'
              event_name: 'MSSQL: Failed to fetch info data (or no data for 30m)'
              priority: INFO
              description: 'Zabbix has not received any data for items for the last 30 minutes.'
              dependencies:
                - name: 'MSSQL: Service is unavailable'
                  expression: 'last(/MSSQL by Zabbix agent 2/net.tcp.service[tcp,{$MSSQL.HOST},{$MSSQL.PORT}])=0'
              tags:
                - tag: scope
                  value: availability
            - uuid: 4ab35137c34845c495bc3837ac1f6f9f
              expression: 'last(/MSSQL by Zabbix agent 2/mssql.uptime)<10m'
              name: 'MSSQL: Service has been restarted'
              event_name: 'MSSQL: Service has been restarted (uptime < 10m)'
              priority: INFO
              description: 'Uptime is less than 10 minutes.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 821f3a9f694349c2afb983d4c26ff090
          name: 'Number of users connected'
          type: DEPENDENT
          key: mssql.user_connections
          description: 'Number of users connected to MSSQL Server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''User Connections'')].cntr_value.first()'
          master_item:
            key: mssql.general_statistics.raw
          tags:
            - tag: component
              value: application
        - uuid: 27e1d9f9005f475784f930c8cbaefa91
          name: 'Errors per second (User errors)'
          type: DEPENDENT
          key: mssql.user_errors_sec.rate
          value_type: FLOAT
          description: 'Number of errors per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Errors/sec'' && @.instance_name==''User Errors'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.sql_errors.raw
          tags:
            - tag: component
              value: error
            - tag: component
              value: performance
        - uuid: 624ea81f4a7c43659f291a2fc7913778
          name: Version
          key: 'mssql.version["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          value_type: CHAR
          description: 'MSSQL Server version.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 12643eb3af884023ab61802559cde946
              expression: 'last(/MSSQL by Zabbix agent 2/mssql.version["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"],#1)<>last(/MSSQL by Zabbix agent 2/mssql.version["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"],#2) and length(last(/MSSQL by Zabbix agent 2/mssql.version["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]))>0'
              name: 'MSSQL: Version has changed'
              event_name: 'MSSQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              description: 'MSSQL version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 081cc2db8e9b481f8ca39e5f02f8f48d
          name: 'Work files created per second'
          type: DEPENDENT
          key: mssql.workfiles_created_sec.rate
          value_type: FLOAT
          description: 'Number of work files created per second. For example, work files can be used to store temporary results for hash joins and hash aggregates.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Workfiles Created/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: performance
          triggers:
            - uuid: 6d25ee02edc14d7497b339627cc0c680
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.workfiles_created_sec.rate,5m)>{$MSSQL.WORK_FILES.MAX}'
              name: 'MSSQL: Number of work files created per second is high'
              event_name: 'MSSQL: Number of work files created per second is high (over {$MSSQL.WORK_FILES.MAX} for 5m)'
              priority: AVERAGE
              description: 'Too many work files created per second to store temporary results for hash joins and hash aggregates.'
              tags:
                - tag: scope
                  value: performance
        - uuid: a2127497537a46b6be10fac14be04259
          name: 'Work tables created per second'
          type: DEPENDENT
          key: mssql.worktables_created_sec.rate
          value_type: FLOAT
          description: 'Number of work tables created per second. For example, work tables can be used to store temporary results for query spool, LOB variables, XML variables, and cursors.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''Worktables Created/sec'')].cntr_value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: performance
          triggers:
            - uuid: 4cd0c8e7089144aeaeb10c4866e89b06
              expression: 'min(/MSSQL by Zabbix agent 2/mssql.worktables_created_sec.rate,5m)>{$MSSQL.WORK_TABLES.MAX}'
              name: 'MSSQL: Number of work tables created per second is high'
              event_name: 'MSSQL: Number of work tables created per second is high (over {$MSSQL.WORK_TABLES.MAX} for 5m)'
              priority: AVERAGE
              description: 'Too many work tables created per second to store temporary results for query spool, LOB variables, XML variables, and cursors.'
              tags:
                - tag: scope
                  value: performance
        - uuid: dbcf930a346c40db9d8fafa89eafe79a
          name: 'Worktables from cache ratio'
          type: DEPENDENT
          key: mssql.worktables_from_cache_ratio
          value_type: FLOAT
          units: '%'
          description: 'Percentage of work tables created where the initial two pages of the work table were not allocated but were immediately available from the work table cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.counter_name==''WorktablesFromCacheRatio'')].cntr_value.first()'
          master_item:
            key: mssql.access_methods.raw
          tags:
            - tag: component
              value: cache
          triggers:
            - uuid: cb3dd51615d447379a3abda929faf881
              expression: 'max(/MSSQL by Zabbix agent 2/mssql.worktables_from_cache_ratio,5m)<{$MSSQL.WORKTABLES_FROM_CACHE_RATIO.MIN.CRIT}'
              name: 'MSSQL: Percentage of work tables available from the work table cache is low'
              event_name: 'MSSQL: Percentage of work tables available from the work table cache is low (below {$MSSQL.WORKTABLES_FROM_CACHE_RATIO.MIN.CRIT}% for 5m)'
              priority: HIGH
              description: 'A value less than 90% may indicate insufficient memory, since execution plans are being dropped, or, on 32-bit systems, may indicate the need for an upgrade to a 64-bit system.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 7fc4f1f9c3df45269972e617ce81f4b2
          name: 'Service''s TCP port state'
          type: SIMPLE
          key: 'net.tcp.service[tcp,{$MSSQL.HOST},{$MSSQL.PORT}]'
          delay: 30s
          description: 'Test the availability of MSSQL Server on a TCP port.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: network
          triggers:
            - uuid: 2ea9eaf463144defbd85340a824f7986
              expression: 'last(/MSSQL by Zabbix agent 2/net.tcp.service[tcp,{$MSSQL.HOST},{$MSSQL.PORT}])=0'
              name: 'MSSQL: Service is unavailable'
              priority: DISASTER
              description: 'The TCP port of the MSSQL Server service is currently unavailable.'
              tags:
                - tag: scope
                  value: availability
      discovery_rules:
        - uuid: 7f7d64674f2b41a69f9330fc050fc582
          name: 'Availability group discovery'
          type: DEPENDENT
          key: mssql.availability.group.discovery
          description: 'Discovery of the existing availability groups.'
          item_prototypes:
            - uuid: a4db74ea2c2c4919ae57d474548c13f1
              name: 'MSSQL AG ''{#GROUP_NAME}'': Primary replica recovery health'
              type: DEPENDENT
              key: 'mssql.primary_recovery_health["{#GROUP_NAME}"]'
              description: |
                Indicates the recovery health of the primary replica:
                0 = In progress
                1 = Online
                2 = Unavailable
              valuemap:
                name: 'MSSQL AG Recovery health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.group_name==''{#GROUP_NAME}'')].primary_recovery_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.availability.group.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: availability-group
              trigger_prototypes:
                - uuid: 7f0c69068dd6415abd193555684ba39d
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.primary_recovery_health["{#GROUP_NAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'': Primary replica recovery health in progress'
                  priority: WARNING
                  description: 'The primary replica is in the synchronization process.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: scope
                      value: notice
            - uuid: ede1746a6614499781c6dec46671cdfa
              name: 'MSSQL AG ''{#GROUP_NAME}'': Primary replica name'
              type: DEPENDENT
              key: 'mssql.primary_replica["{#GROUP_NAME}"]'
              value_type: CHAR
              description: 'Name of the server instance that is hosting the current primary replica.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.group_name==''{#GROUP_NAME}'')].primary_replica.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'mssql.availability.group.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: availability-group
            - uuid: 49612aea8b164a79b994d2155c70b491
              name: 'MSSQL AG ''{#GROUP_NAME}'': Secondary replica recovery health'
              type: DEPENDENT
              key: 'mssql.secondary_recovery_health["{#GROUP_NAME}"]'
              description: |
                Indicates the recovery health of a secondary replica:
                0 = In progress
                1 = Online
                2 = Unavailable
              valuemap:
                name: 'MSSQL AG Recovery health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.group_name==''{#GROUP_NAME}'')].secondary_recovery_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.availability.group.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: availability-group
              trigger_prototypes:
                - uuid: 4fc114d3f43741b38bdf7b8b73a6fe3e
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.secondary_recovery_health["{#GROUP_NAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'': Secondary replica recovery health in progress'
                  priority: WARNING
                  description: 'The secondary replica is in the synchronization process.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: scope
                      value: notice
            - uuid: f6a776b81e9d445e9b401ecdc781fe26
              name: 'MSSQL AG ''{#GROUP_NAME}'': Synchronization health'
              type: DEPENDENT
              key: 'mssql.synchronization_health["{#GROUP_NAME}"]'
              description: |
                Reflects a rollup of the `synchronization_health` of all availability replicas in the availability group:
                0 = Not healthy. None of the availability replicas have a healthy synchronization.
                1 = Partially healthy. The synchronization of some, but not all, availability replicas is healthy.
                2 = Healthy. The synchronization of every availability replica is healthy.
              valuemap:
                name: 'MSSQL AG Synchronization health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.group_name==''{#GROUP_NAME}'')].synchronization_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.availability.group.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: availability-group
              trigger_prototypes:
                - uuid: 1aa3dd01e7654dea903010b47f166596
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.synchronization_health["{#GROUP_NAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'': All replicas unhealthy'
                  priority: DISASTER
                  description: 'None of the availability replicas have a healthy synchronization.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: scope
                      value: availability
                - uuid: 02766fa029c14e85914e20b81f14be2c
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.synchronization_health["{#GROUP_NAME}"])=1'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'': Some replicas unhealthy'
                  priority: HIGH
                  description: 'The synchronization health of some, but not all, availability replicas is healthy.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: scope
                      value: availability
          master_item:
            key: 'mssql.availability.group.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          lld_macro_paths:
            - lld_macro: '{#GROUP_NAME}'
              path: $.group_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: 13116bb9e52040718b40f0a6e734342a
          name: 'Database discovery'
          type: DEPENDENT
          key: mssql.database.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DBNAME}'
                value: '{$MSSQL.DBNAME.MATCHES}'
              - macro: '{#DBNAME}'
                value: '{$MSSQL.DBNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Scanning databases in DBMS.'
          item_prototypes:
            - uuid: 39264e40f3304b3fb5d85fbac83008f8
              name: 'MSSQL DB ''{#DBNAME}'': Last diff backup duration'
              type: DEPENDENT
              key: 'mssql.backup.diff.duration["{#DBNAME}"]'
              units: s
              description: 'Duration of the last differential backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''I'')].duration.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 45613ebe8c77431fbfa3ab00d39e68e5
              name: 'MSSQL DB ''{#DBNAME}'': Last diff backup (time ago)'
              type: DEPENDENT
              key: 'mssql.backup.diff["{#DBNAME}"]'
              units: s
              description: 'The amount of time since the last differential backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''I'')].time_since_last_backup.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 4ff9a2f1c06347a291e99eb4269d87a5
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.backup.diff["{#DBNAME}"])>{$MSSQL.BACKUP_DIFF.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_DIFF.USED:"{#DBNAME}"}=1'
                  name: 'MSSQL: DB ''{#DBNAME}'': Diff backup is old'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Diff backup older than {$MSSQL.BACKUP_DIFF.CRIT:"{#DBNAME}"}'
                  opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
                  priority: HIGH
                  description: 'The differential backup has not been executed for a long time.'
                  manual_close: 'YES'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
                - uuid: 49260837210a4086a6f2a4183cefbf8c
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.backup.diff["{#DBNAME}"])>{$MSSQL.BACKUP_DIFF.WARN:"{#DBNAME}"} and {$MSSQL.BACKUP_DIFF.USED:"{#DBNAME}"}=1'
                  name: 'MSSQL: DB ''{#DBNAME}'': Diff backup is old'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Diff backup older than {$MSSQL.BACKUP_DIFF.WARN:"{#DBNAME}"}'
                  opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
                  priority: WARNING
                  description: 'The differential backup has not been executed for a long time.'
                  manual_close: 'YES'
                  dependencies:
                    - name: 'MSSQL: DB ''{#DBNAME}'': Diff backup is old'
                      expression: 'last(/MSSQL by Zabbix agent 2/mssql.backup.diff["{#DBNAME}"])>{$MSSQL.BACKUP_DIFF.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_DIFF.USED:"{#DBNAME}"}=1'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
            - uuid: 5da7fa72e56740d3938e8bb5bb32839e
              name: 'MSSQL DB ''{#DBNAME}'': Last full backup duration'
              type: DEPENDENT
              key: 'mssql.backup.full.duration["{#DBNAME}"]'
              units: s
              description: 'Duration of the last full backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''D'')].duration.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 32c38b20af8f42698fb96bf0bbb05dec
              name: 'MSSQL DB ''{#DBNAME}'': Last full backup (time ago)'
              type: DEPENDENT
              key: 'mssql.backup.full["{#DBNAME}"]'
              units: s
              description: 'The amount of time since the last full backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''D'')].time_since_last_backup.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: ba1b19c9513f4adeba3e6f300c08748d
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.backup.full["{#DBNAME}"])>{$MSSQL.BACKUP_FULL.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_FULL.USED:"{#DBNAME}"}=1'
                  name: 'MSSQL: DB ''{#DBNAME}'': Full backup is old'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Full backup older than {$MSSQL.BACKUP_FULL.CRIT:"{#DBNAME}"}'
                  opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
                  priority: HIGH
                  description: 'The full backup has not been executed for a long time.'
                  manual_close: 'YES'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
                - uuid: a8e099c8276f435cb4d55623be443db5
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.backup.full["{#DBNAME}"])>{$MSSQL.BACKUP_FULL.WARN:"{#DBNAME}"} and {$MSSQL.BACKUP_FULL.USED:"{#DBNAME}"}=1'
                  name: 'MSSQL: DB ''{#DBNAME}'': Full backup is old'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Full backup older than {$MSSQL.BACKUP_FULL.WARN:"{#DBNAME}"}'
                  opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
                  priority: WARNING
                  description: 'The full backup has not been executed for a long time.'
                  manual_close: 'YES'
                  dependencies:
                    - name: 'MSSQL: DB ''{#DBNAME}'': Full backup is old'
                      expression: 'last(/MSSQL by Zabbix agent 2/mssql.backup.full["{#DBNAME}"])>{$MSSQL.BACKUP_FULL.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_FULL.USED:"{#DBNAME}"}=1'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: a7aaa846c6694ddf9daf5d18db5a3037
              name: 'MSSQL DB ''{#DBNAME}'': Last log backup duration'
              type: DEPENDENT
              key: 'mssql.backup.log.duration["{#DBNAME}"]'
              units: s
              description: 'Duration of the last log backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''L'')].duration.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 453a48800bce43b58a372b7466b944bd
              name: 'MSSQL DB ''{#DBNAME}'': Last log backup (time ago)'
              type: DEPENDENT
              key: 'mssql.backup.log["{#DBNAME}"]'
              units: s
              description: 'The amount of time since the last log backup.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.type==''L'')].time_since_last_backup.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 6800612ef91f4f149e24c4cf9a9f915c
              name: 'MSSQL DB ''{#DBNAME}'': Get last backup'
              type: DEPENDENT
              key: 'mssql.backup.raw["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'The item gets information about backup processes for {#DBNAME}.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')]'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'mssql.last.backup.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: f8bc0815cbc1471eb949429a95503287
              name: 'MSSQL DB ''{#DBNAME}'': Recovery model'
              type: DEPENDENT
              key: 'mssql.backup.recovery_model["{#DBNAME}"]'
              description: |
                Recovery model selected:
                1 = Full
                2 = Bulk_logged
                3 = Simple
              valuemap:
                name: 'MSSQL Recovery model'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[0].db_recovery_model'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '1'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'mssql.backup.raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: ccd715be77234994b8931ca89abb015a
              name: 'MSSQL DB ''{#DBNAME}'': Active transactions'
              type: DEPENDENT
              key: 'mssql.db.active_transactions["{#DBNAME}"]'
              description: 'Number of active transactions for the database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Active Transactions'')].cntr_value.first()'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: cba4bf9b39fc4cd69152f15cfd0edb56
              name: 'MSSQL DB ''{#DBNAME}'': Data file size'
              type: DEPENDENT
              key: 'mssql.db.data_files_size["{#DBNAME}"]'
              units: B
              description: 'Cumulative size of all the data files in the database including any automatic growth. Monitoring this counter is useful, for example, for determining the correct size of `tempdb`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Data File(s) Size (KB)'')].cntr_value.first()'
                - type: MULTIPLIER
                  parameters:
                    - '1024'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 9cd2a1a539604c68b4540d424a608d4c
              name: 'MSSQL DB ''{#DBNAME}'': Log bytes flushed per second'
              type: DEPENDENT
              key: 'mssql.db.log_bytes_flushed_sec.rate["{#DBNAME}"]'
              value_type: FLOAT
              units: Bps
              description: 'Total number of log bytes flushed per second. Useful for determining trends and utilization of the transaction log.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Bytes Flushed/sec'')].cntr_value.first()'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: ff2f2fd39e11418ea93b79ba27b73e3d
              name: 'MSSQL DB ''{#DBNAME}'': Log file size'
              type: DEPENDENT
              key: 'mssql.db.log_files_size["{#DBNAME}"]'
              units: B
              description: 'Cumulative size of all the transaction log files in the database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log File(s) Size (KB)'')].cntr_value.first()'
                - type: MULTIPLIER
                  parameters:
                    - '1024'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 7466329cc603401095def32026d8182d
              name: 'MSSQL DB ''{#DBNAME}'': Log file used size'
              type: DEPENDENT
              key: 'mssql.db.log_files_used_size["{#DBNAME}"]'
              units: B
              description: 'Cumulative size of all the log files in the database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log File(s) Used Size (KB)'')].cntr_value.first()'
                - type: MULTIPLIER
                  parameters:
                    - '1024'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 6c874bd1dd7746b4894d5b25e3de0f7c
              name: 'MSSQL DB ''{#DBNAME}'': Log flushes per second'
              type: DEPENDENT
              key: 'mssql.db.log_flushes_sec.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of log flushes per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Flushes/sec'')].cntr_value.first()'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 64dc4faefc0f4709b5e740c036e9a272
              name: 'MSSQL DB ''{#DBNAME}'': Log flush waits per second'
              type: DEPENDENT
              key: 'mssql.db.log_flush_waits_sec.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of commits per second waiting for the log flush.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Flush Waits/sec'')].cntr_value.first()'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 4bdf258b6902407cbcc7b27cc906ee48
                  expression: 'min(/MSSQL by Zabbix agent 2/mssql.db.log_flush_waits_sec.rate["{#DBNAME}"],5m)>{$MSSQL.LOG_FLUSH_WAITS.MAX:"{#DBNAME}"}'
                  name: 'MSSQL: DB ''{#DBNAME}'': Number of commits waiting for the log flush is high'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Number of commits waiting for the log flush is high (over {$MSSQL.LOG_FLUSH_WAITS.MAX:"{#DBNAME}"}/sec for 5m)'
                  priority: WARNING
                  description: 'Too many commits are waiting for the log flush.'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: performance
            - uuid: 1e4289626cd540dbbc9e54be9d6a0836
              name: 'MSSQL DB ''{#DBNAME}'': Log flush wait time'
              type: DEPENDENT
              key: 'mssql.db.log_flush_wait_time["{#DBNAME}"]'
              value_type: FLOAT
              units: ms
              description: 'Total wait time (in milliseconds) to flush the log. On an Always On secondary database, this value indicates the wait time for log records to be hardened to disk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Flush Wait Time'')].cntr_value.first()'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 1baacf9d55d746599a28c407087ea5fb
                  expression: 'min(/MSSQL by Zabbix agent 2/mssql.db.log_flush_wait_time["{#DBNAME}"],5m)>{$MSSQL.LOG_FLUSH_WAIT_TIME.MAX:"{#DBNAME}"}'
                  name: 'MSSQL: DB ''{#DBNAME}'': Total wait time to flush the log is high'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Total wait time to flush the log is high (over {$MSSQL.LOG_FLUSH_WAIT_TIME.MAX:"{#DBNAME}"}ms for 5m)'
                  priority: WARNING
                  description: 'The wait time to flush the log is too long.'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: performance
            - uuid: e0ebbdccf06e4bd580944eca894fd765
              name: 'MSSQL DB ''{#DBNAME}'': Log growths'
              type: DEPENDENT
              key: 'mssql.db.log_growths["{#DBNAME}"]'
              description: 'Total number of times the transaction log for the database has been expanded.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Growths'')].cntr_value.first()'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: f4705df239ff4b52a7594adc8bff1786
              name: 'MSSQL DB ''{#DBNAME}'': Log shrinks'
              type: DEPENDENT
              key: 'mssql.db.log_shrinks["{#DBNAME}"]'
              description: 'Total number of times the transaction log for the database has been shrunk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Shrinks'')].cntr_value.first()'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 23f7b754af114e779bfb12b954041a3a
              name: 'MSSQL DB ''{#DBNAME}'': Log truncations'
              type: DEPENDENT
              key: 'mssql.db.log_truncations["{#DBNAME}"]'
              description: 'Number of times the transaction log has been shrunk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Log Truncations'')].cntr_value.first()'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 622cd26e368144c7b4b4a760be6e9d80
              name: 'MSSQL DB ''{#DBNAME}'': Percent log used'
              type: DEPENDENT
              key: 'mssql.db.percent_log_used["{#DBNAME}"]'
              value_type: FLOAT
              units: '%'
              description: 'Percentage of log space in use.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Percent Log Used'')].cntr_value.first()'
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: f2a80dfd54ca4e2391adbc7006118987
                  expression: 'min(/MSSQL by Zabbix agent 2/mssql.db.percent_log_used["{#DBNAME}"],5m)>{$MSSQL.PERCENT_LOG_USED.MAX:"{#DBNAME}"}'
                  name: 'MSSQL: DB ''{#DBNAME}'': Percent of log usage is high'
                  event_name: 'MSSQL: DB ''{#DBNAME}'': Percent of log usage is high (over {$MSSQL.PERCENT_LOG_USED.MAX:"{#DBNAME}"}% for 5m)'
                  priority: WARNING
                  description: 'There''s not enough space left in the log.'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: performance
            - uuid: 84e28628c11d4c35a7ee7b1a714c7b59
              name: 'MSSQL DB ''{#DBNAME}'': Get performance counters'
              type: DEPENDENT
              key: 'mssql.db.perf_raw["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'The item gets server status information for {#DBNAME}.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.object_name=~''.*Databases'' && @.instance_name==''{#DBNAME}'')]'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'mssql.perfcounter.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 2032b8a3889a4a9f941529c4b62aa860
              name: 'MSSQL DB ''{#DBNAME}'': State'
              type: DEPENDENT
              key: 'mssql.db.state["{#DBNAME}"]'
              description: |
                0 = Online
                1 = Restoring
                2 = Recovering | SQL Server 2008 and later
                3 = Recovery_pending | SQL Server 2008 and later
                4 = Suspect
                5 = Emergency | SQL Server 2008 and later
                6 = Offline | SQL Server 2008 and later
                7 = Copying | Azure SQL Database Active Geo-Replication
                10 = Offline_secondary | Azure SQL Database Active Geo-Replication
              valuemap:
                name: 'MSSQL DB state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''State'')].cntr_value.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 0963794ed0b0483bbaa9dc0858c9f445
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.db.state["{#DBNAME}"])>1'
                  name: 'MSSQL: DB ''{#DBNAME}'': State is {ITEM.VALUE}'
                  priority: HIGH
                  description: 'The DB has a non-working state.'
                  tags:
                    - tag: database
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
            - uuid: e2f693fb31d84532a67d6f7e2f479acc
              name: 'MSSQL DB ''{#DBNAME}'': Transactions per second'
              type: DEPENDENT
              key: 'mssql.db.transactions_sec.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of transactions started for the database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.counter_name==''Transactions/sec'')].cntr_value.first()'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'mssql.db.perf_raw["{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
          trigger_prototypes:
            - uuid: 7b708b7c408f4b2fb5d1bc6d017d6c68
              expression: 'last(/MSSQL by Zabbix agent 2/mssql.backup.log["{#DBNAME}"])>{$MSSQL.BACKUP_LOG.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_LOG.USED:"{#DBNAME}"}=1 and last(/MSSQL by Zabbix agent 2/mssql.backup.recovery_model["{#DBNAME}"])<>3'
              name: 'MSSQL: DB ''{#DBNAME}'': Log backup is old'
              event_name: 'MSSQL: DB ''{#DBNAME}'': Log backup older than {$MSSQL.BACKUP_LOG.CRIT:"{#DBNAME}"}'
              opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The log backup has not been executed for a long time.'
              manual_close: 'YES'
              tags:
                - tag: database
                  value: '{#DBNAME}'
                - tag: scope
                  value: availability
            - uuid: dc580ac10b3f451686b8163bdf21b759
              expression: 'last(/MSSQL by Zabbix agent 2/mssql.backup.log["{#DBNAME}"])>{$MSSQL.BACKUP_LOG.WARN:"{#DBNAME}"} and {$MSSQL.BACKUP_LOG.USED:"{#DBNAME}"}=1 and last(/MSSQL by Zabbix agent 2/mssql.backup.recovery_model["{#DBNAME}"])<>3'
              name: 'MSSQL: DB ''{#DBNAME}'': Log backup is old'
              event_name: 'MSSQL: DB ''{#DBNAME}'': Log backup older than {$MSSQL.BACKUP_LOG.WARN:"{#DBNAME}"}'
              opdata: 'Time since last backup: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The log backup has not been executed for a long time.'
              manual_close: 'YES'
              dependencies:
                - name: 'MSSQL: DB ''{#DBNAME}'': Log backup is old'
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.backup.log["{#DBNAME}"])>{$MSSQL.BACKUP_LOG.CRIT:"{#DBNAME}"} and {$MSSQL.BACKUP_LOG.USED:"{#DBNAME}"}=1 and last(/MSSQL by Zabbix agent 2/mssql.backup.recovery_model["{#DBNAME}"])<>3'
              tags:
                - tag: database
                  value: '{#DBNAME}'
                - tag: scope
                  value: availability
          graph_prototypes:
            - uuid: 8175463b48da43b596b0fd733dfa1b2e
              name: 'DB ''{#DBNAME}'': Log size'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'MSSQL by Zabbix agent 2'
                    key: 'mssql.db.log_files_size["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'MSSQL by Zabbix agent 2'
                    key: 'mssql.db.log_files_used_size["{#DBNAME}"]'
            - uuid: 768ec0884405473fb269f8b465b214e6
              name: 'DB ''{#DBNAME}'': Number of Log changes'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'MSSQL by Zabbix agent 2'
                    key: 'mssql.db.log_growths["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'MSSQL by Zabbix agent 2'
                    key: 'mssql.db.log_shrinks["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'MSSQL by Zabbix agent 2'
                    key: 'mssql.db.log_truncations["{#DBNAME}"]'
            - uuid: d60af32a941e41ed9d0a65f996df89e4
              name: 'DB ''{#DBNAME}'': Size'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'MSSQL by Zabbix agent 2'
                    key: 'mssql.db.data_files_size["{#DBNAME}"]'
          master_item:
            key: 'mssql.db.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          lld_macro_paths:
            - lld_macro: '{#DBNAME}'
              path: $.dbname
            - lld_macro: '{#RECOVERY_MODEL}'
              path: $.recovery_model
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          overrides:
            - name: 'Log backup'
              step: '1'
              filter:
                conditions:
                  - macro: '{#RECOVERY_MODEL}'
                    value: '3'
              operations:
                - operationobject: TRIGGER_PROTOTYPE
                  operator: LIKE
                  value: 'Log backup is old'
                  discover: NO_DISCOVER
        - uuid: 749fe36645994fc2aa45d7916862b893
          name: 'Job discovery'
          type: DEPENDENT
          key: mssql.job.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#JOBNAME}'
                value: '{$MSSQL.JOB.MATCHES}'
              - macro: '{#JOBNAME}'
                value: '{$MSSQL.JOB.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Scanning jobs in DBMS.'
          item_prototypes:
            - uuid: 7503acf68ad44180ace4113d654752d1
              name: 'MSSQL Job ''{#JOBNAME}'': Enabled'
              type: DEPENDENT
              key: 'mssql.job.enabled["{#JOBNAME}"]'
              description: |
                The possible values of the job status:
                0 = Disabled
                1 = Enabled
              valuemap:
                name: 'MSSQL - Yes / No'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.enabled
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
            - uuid: a42c8a24b329498581b8a81c13d16076
              name: 'MSSQL Job ''{#JOBNAME}'': Last run date-time'
              type: DEPENDENT
              key: 'mssql.job.lastrundatetime["{#JOBNAME}"]'
              units: unixtime
              description: 'The last date-time of the job run.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.last_run_date_time
                - type: JAVASCRIPT
                  parameters:
                    - 'return value == ''null'' ? 0 : Math.floor(new Date(value) / 1000);'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
            - uuid: b86b627c1a234d409950345b9d7a1f73
              name: 'MSSQL Job ''{#JOBNAME}'': Last run status message'
              type: DEPENDENT
              key: 'mssql.job.lastrunstatusmessage["{#JOBNAME}"]'
              value_type: TEXT
              description: 'An informational message about the last run of the job.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.last_run_status_message
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
            - uuid: fcc4d2cfa5674d33b8831e03b23f40c5
              name: 'MSSQL Job ''{#JOBNAME}'': Next run date-time'
              type: DEPENDENT
              key: 'mssql.job.nextrundatetime["{#JOBNAME}"]'
              units: unixtime
              description: 'The next date-time of the job run.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.next_run_date_time
                - type: JAVASCRIPT
                  parameters:
                    - 'return value == ''null'' ? 0 : Math.floor(new Date(value) / 1000);'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
            - uuid: 7bb5fb0220ef4649955049ee1b6d6c73
              name: 'MSSQL Job ''{#JOBNAME}'': Run status'
              type: DEPENDENT
              key: 'mssql.job.runstatus["{#JOBNAME}"]'
              description: |
                The possible values of the job status:
                0 ⇒ Failed
                1 ⇒ Succeeded
                2 ⇒ Retry
                3 ⇒ Canceled
                4 ⇒ Running
              valuemap:
                name: 'MSSQL Job Run Status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.run_status
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
              trigger_prototypes:
                - uuid: f404c4f644ee450ebbd269eb7c8897d9
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.job.runstatus["{#JOBNAME}"])=0'
                  name: 'MSSQL: Job ''{#JOBNAME}'': Failed to run'
                  priority: WARNING
                  description: 'The last run of the job has failed.'
                  manual_close: 'YES'
                  tags:
                    - tag: mssql-job
                      value: '{#JOBNAME}'
                    - tag: scope
                      value: performance
            - uuid: 6ae51f0fd7c04e01aa9e1af302d461d0
              name: 'MSSQL Job ''{#JOBNAME}'': Run duration'
              type: DEPENDENT
              key: 'mssql.job.run_duration["{#JOBNAME}"]'
              units: s
              description: 'Duration of the last-run job.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.run_duration
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'mssql.job.status_raw["{#JOBNAME}"]'
              tags:
                - tag: component
                  value: mssql-job
                - tag: mssql-job
                  value: '{#JOBNAME}'
              trigger_prototypes:
                - uuid: b8bf7358712242609e64ce60303eb80f
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.job.run_duration["{#JOBNAME}"])>{$MSSQL.BACKUP_DURATION.WARN:"{#JOBNAME}"}'
                  name: 'MSSQL: Job ''{#JOBNAME}'': Job duration is high'
                  event_name: 'MSSQL: Job ''{#JOBNAME}'': Job duration is greater than {$MSSQL.BACKUP_DURATION.WARN:"{#JOBNAME}"}'
                  opdata: 'Job duration: {ITEM.LASTVALUE1}'
                  priority: WARNING
                  description: 'The job is taking too long.'
                  manual_close: 'YES'
                  tags:
                    - tag: mssql-job
                      value: '{#JOBNAME}'
                    - tag: scope
                      value: performance
            - uuid: 1bd249b766384ec28f9dfa0212ac3472
              name: 'MSSQL Job ''{#JOBNAME}'': Get job status'
              type: DEPENDENT
              key: 'mssql.job.status_raw["{#JOBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'The item gets the status of SQL agent job {#JOBNAME}.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.job_name==''{#JOBNAME}'')].first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'mssql.job.status.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: raw
                - tag: mssql-job
                  value: '{#JOBNAME}'
          master_item:
            key: 'mssql.job.status.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          lld_macro_paths:
            - lld_macro: '{#JOBNAME}'
              path: $.job_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: f47cad40c2dd42d4a80fb5628b8cc790
          name: 'Local database discovery'
          type: DEPENDENT
          key: mssql.local.db.discovery
          description: 'Discovery of the local availability databases.'
          item_prototypes:
            - uuid: af88b98cb0274de89dbf3b65a1b5c107
              name: 'MSSQL AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': Suspended'
              type: DEPENDENT
              key: 'mssql.local_db.is_suspended["{#DBNAME}"]'
              description: |
                Database state:
                0 = Resumed
                1 = Suspended
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'' && @.group_name==''{#GROUP_NAME}'')].is_suspended.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.local.db.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: local-db
                - tag: local-db
                  value: '{#DBNAME}'
            - uuid: b0f834ec67b743a994acc4d2681c594f
              name: 'MSSQL AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': State'
              type: DEPENDENT
              key: 'mssql.local_db.state["{#DBNAME}"]'
              description: |
                0 = Online
                1 = Restoring
                2 = Recovering
                3 = Recovery pending
                4 = Suspect
                5 = Emergency
                6 = Offline
              valuemap:
                name: 'MSSQL DB state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'' && @.group_name==''{#GROUP_NAME}'')].database_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.local.db.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: local-db
                - tag: local-db
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 7eb2d73718b0451790c5d81d63517c1b
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.local_db.state["{#DBNAME}"])>0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': "{#DBNAME}" is {ITEM.VALUE}'
                  priority: WARNING
                  description: 'The local availability database has a non-working state.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: local-db
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
            - uuid: bdbe4f929d0247baa8522b0bae2e3b3e
              name: 'MSSQL AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': Synchronization health'
              type: DEPENDENT
              key: 'mssql.local_db.synchronization_health["{#DBNAME}"]'
              description: |
                Reflects the intersection of the synchronization state of a database that is joined to the availability group on the availability replica and the availability mode of the availability replica (synchronous-commit or asynchronous-commit mode):
                0 = Not healthy. The synchronization_state of the database is 0 ("Not synchronizing").
                1 = Partially healthy. A database on a synchronous-commit availability replica is considered partially healthy if synchronization_state is 1 ("Synchronizing").
                2 = Healthy. A database on an synchronous-commit availability replica is considered healthy if synchronization_state is 2 ("Synchronized"), and a database on an asynchronous-commit availability replica is considered healthy if synchronization_state is 1 ("Synchronizing").
              valuemap:
                name: 'MSSQL AG Synchronization health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'' && @.group_name==''{#GROUP_NAME}'')].synchronization_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.local.db.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: local-db
                - tag: local-db
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 47ba6c51cf34498a991b68b341210eca
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.local_db.synchronization_health["{#DBNAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': "{#DBNAME}" is Not healthy'
                  priority: HIGH
                  description: 'The synchronization state of the local availability database is "Not synchronizing".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: local-db
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
                - uuid: 112b6ba5294946c7973d278392266439
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.local_db.synchronization_health["{#DBNAME}"])=1'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Local DB ''{#DBNAME}'': "{#DBNAME}" is Partially healthy'
                  priority: AVERAGE
                  description: 'A database on a synchronous-commit availability replica is considered partially healthy if synchronization state is "Synchronizing".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: local-db
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
          master_item:
            key: 'mssql.local.db.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          lld_macro_paths:
            - lld_macro: '{#DBNAME}'
              path: $.dbname
            - lld_macro: '{#GROUP_NAME}'
              path: $.group_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: 7c12efa1fd27435a968d910abcb1c095
          name: 'Mirroring discovery'
          type: DEPENDENT
          key: mssql.mirroring.discovery
          description: 'To see the row for a database other than master or tempdb, you must either be the database owner or have at least ALTER ANY DATABASE or VIEW ANY DATABASE server-level permission or CREATE DATABASE permission in the master database. To see non-NULL values on a mirror database, you must be a member of the sysadmin fixed server role.'
          item_prototypes:
            - uuid: ad3744d9c53f44008f6557a25333268d
              name: 'MSSQL Mirroring ''{#DBNAME}'': Role'
              type: DEPENDENT
              key: 'mssql.mirroring.role["{#DBNAME}"]'
              description: |
                Current role of the local database plays in the database mirroring session.
                1 = Principal
                2 = Mirror
              valuemap:
                name: 'MSSQL Mirroring Role'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')].mirroring_role.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.mirroring.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: mssql-mirroring
                - tag: mssql-mirroring
                  value: '{#DBNAME}'
            - uuid: da278bc7d59b4590a5a869d800b57835
              name: 'MSSQL Mirroring ''{#DBNAME}'': Role sequence'
              type: DEPENDENT
              key: 'mssql.mirroring.role_sequence["{#DBNAME}"]'
              description: 'The number of times that mirroring partners have switched the principal and mirror roles due to a failover or forced service.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')].mirroring_role_sequence.first()'
                - type: SIMPLE_CHANGE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.mirroring.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: mssql-mirroring
                - tag: mssql-mirroring
                  value: '{#DBNAME}'
            - uuid: ff0f198e003d4804a4ef471336b7b64b
              name: 'MSSQL Mirroring ''{#DBNAME}'': Safety level'
              type: DEPENDENT
              key: 'mssql.mirroring.safety_level["{#DBNAME}"]'
              description: |
                Safety setting for updates on the mirror database:
                0 = Unknown state
                1 = Off [asynchronous]
                2 = Full [synchronous]
              valuemap:
                name: 'MSSQL Safety level'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')].mirroring_safety_level.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.mirroring.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: mssql-mirroring
                - tag: mssql-mirroring
                  value: '{#DBNAME}'
            - uuid: c0578a39b0a349d3bc4418bd25efbfd9
              name: 'MSSQL Mirroring ''{#DBNAME}'': State'
              type: DEPENDENT
              key: 'mssql.mirroring.state["{#DBNAME}"]'
              description: |
                State of the mirror database and of the database mirroring session.
                0 = Suspended
                1 = Disconnected from the other partner
                2 = Synchronizing
                3 = Pending failover
                4 = Synchronized
                5 = The partners are not synchronized. Failover is not possible now.
                6 = The partners are synchronized. Failover is potentially possible. For information about the requirements for the failover, see Database Mirroring Operating Modes: https://learn.microsoft.com/en-us/sql/database-engine/database-mirroring/database-mirroring-operating-modes?view=sql-server-ver16.
              valuemap:
                name: 'MSSQL Mirroring State'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')].mirroring_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.mirroring.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: mssql-mirroring
                - tag: mssql-mirroring
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 33ef90679bcb47f09cc0c5372ea54fdc
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.mirroring.state["{#DBNAME}"])=3'
                  name: 'MSSQL: Mirroring ''{#DBNAME}'': "{#DBNAME}" is {ITEM.VALUE}'
                  priority: WARNING
                  description: 'The state of the mirror database and of the database mirroring session is "Pending failover".'
                  tags:
                    - tag: mssql-mirroring
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
                - uuid: 4e7813c78c8f47808cfb5c970de2ad99
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.mirroring.state["{#DBNAME}"])=5'
                  name: 'MSSQL: Mirroring ''{#DBNAME}'': "{#DBNAME}" is {ITEM.VALUE}'
                  priority: HIGH
                  description: 'The state of the mirror database and of the database mirroring session is "Not synchronized". The partners are not synchronized. A failover is not possible now.'
                  tags:
                    - tag: mssql-mirroring
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
                - uuid: 5554197e2079495ab49491ca0855ccee
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.mirroring.state["{#DBNAME}"])>=0 and last(/MSSQL by Zabbix agent 2/mssql.mirroring.state["{#DBNAME}"])<=2'
                  name: 'MSSQL: Mirroring ''{#DBNAME}'': "{#DBNAME}" is {ITEM.VALUE}'
                  priority: INFO
                  description: 'The state of the mirror database and of the database mirroring session is "Suspended", "Disconnected from the other partner", or "Synchronizing".'
                  tags:
                    - tag: mssql-mirroring
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
            - uuid: 84be4a93d1774b5096831c082b9154de
              name: 'MSSQL Mirroring ''{#DBNAME}'': Witness state'
              type: DEPENDENT
              key: 'mssql.mirroring.witness_state["{#DBNAME}"]'
              description: |
                State of the witness in the database mirroring session of the database:
                0 = Unknown
                1 = Connected
                2 = Disconnected
              valuemap:
                name: 'MSSQL Witness state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'')].mirroring_witness_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.mirroring.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: mssql-mirroring
                - tag: mssql-mirroring
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 3a3903f3008b4360a93e45d94f344a42
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.mirroring.witness_state["{#DBNAME}"])=2'
                  name: 'MSSQL: Mirroring ''{#DBNAME}'': "{#DBNAME}" Witness is disconnected'
                  priority: WARNING
                  description: 'The state of the witness in the database mirroring session of the database is "Disconnected".'
                  tags:
                    - tag: mssql-mirroring
                      value: '{#DBNAME}'
                    - tag: scope
                      value: availability
          graph_prototypes:
            - uuid: 37c8f69765e3456bbfdfbe096c78e910
              name: 'Mirroring ''{#DBNAME}'': States'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'MSSQL by Zabbix agent 2'
                    key: 'mssql.mirroring.state["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'MSSQL by Zabbix agent 2'
                    key: 'mssql.mirroring.witness_state["{#DBNAME}"]'
          master_item:
            key: 'mssql.mirroring.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          lld_macro_paths:
            - lld_macro: '{#DBNAME}'
              path: $.dbname
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: faaa289d832d4dcda5de868d832a7d31
          name: 'Non-local database discovery'
          type: DEPENDENT
          key: mssql.non.local.db.discovery
          description: 'Discovery of the non-local (not local to SQL Server instance) availability databases.'
          item_prototypes:
            - uuid: ab9c87918819445f8c4eaf3fd3226a5a
              name: 'MSSQL AG ''{#GROUP_NAME}'' Non-Local DB ''*{#REPLICA_NAME}*{#DBNAME}'': Log queue size'
              type: DEPENDENT
              key: 'mssql.non-local_db.log_send_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"]'
              units: B
              description: 'Amount of the log records of the primary database that has not been sent to the secondary databases.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'' && @.group_name==''{#GROUP_NAME}'' && @.replica_name==''{#REPLICA_NAME}'')].log_send_queue_size.first()'
                - type: MULTIPLIER
                  parameters:
                    - '1024'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.nonlocal.db.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: non-local-db
                - tag: non-local-db
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 16b1fc9ee0e340ac8f1742d04ffc6393
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.non-local_db.log_send_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#1)>last(/MSSQL by Zabbix agent 2/mssql.non-local_db.log_send_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#2) and last(/MSSQL by Zabbix agent 2/mssql.non-local_db.log_send_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#2)>last(/MSSQL by Zabbix agent 2/mssql.non-local_db.log_send_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#3)'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Non-Local DB ''*{#REPLICA_NAME}*{#DBNAME}'': Log queue size is growing'
                  priority: HIGH
                  description: 'The log records of the primary database are not sent to the secondary databases.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: non-local-db
                      value: '{#DBNAME}'
                    - tag: scope
                      value: capacity
            - uuid: dd2a6b660ed148e7b1c729ffb2a4ad76
              name: 'MSSQL AG ''{#GROUP_NAME}'' Non-Local DB ''*{#REPLICA_NAME}*{#DBNAME}'': Redo log queue size'
              type: DEPENDENT
              key: 'mssql.non-local_db.redo_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"]'
              units: B
              description: 'Amount of log records in the log files of the secondary replica that has not yet been redone.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.dbname==''{#DBNAME}'' && @.group_name==''{#GROUP_NAME}'' && @.replica_name==''{#REPLICA_NAME}'')].redo_queue_size.first()'
                - type: MULTIPLIER
                  parameters:
                    - '1024'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.nonlocal.db.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: non-local-db
                - tag: non-local-db
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: b4748575543a451c85fa013e4867e38f
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.non-local_db.redo_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#1)>last(/MSSQL by Zabbix agent 2/mssql.non-local_db.redo_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#2) and last(/MSSQL by Zabbix agent 2/mssql.non-local_db.redo_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#2)>last(/MSSQL by Zabbix agent 2/mssql.non-local_db.redo_queue_size["{#GROUP_NAME}*{#REPLICA_NAME}*{#DBNAME}"],#3)'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Non-Local DB ''*{#REPLICA_NAME}*{#DBNAME}'': Redo log queue size is growing'
                  priority: HIGH
                  description: 'The log records in the log files of the secondary replica have not yet been redone.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: non-local-db
                      value: '{#DBNAME}'
                    - tag: scope
                      value: capacity
          master_item:
            key: 'mssql.nonlocal.db.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          lld_macro_paths:
            - lld_macro: '{#DBNAME}'
              path: $.dbname
            - lld_macro: '{#GROUP_NAME}'
              path: $.group_name
            - lld_macro: '{#REPLICA_NAME}'
              path: $.replica_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: ee0ccf3f0e6e4bfbb500942811874ece
          name: 'Quorum discovery'
          type: DEPENDENT
          key: mssql.quorum.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CLUSTER_NAME}'
                value: ^.+$
          description: 'Discovery of the quorum of the WSFC cluster.'
          item_prototypes:
            - uuid: 3ddd6e3780de4b7a8cb2e37d515d5a8f
              name: 'MSSQL Cluster ''{#CLUSTER_NAME}'': Quorum state'
              type: DEPENDENT
              key: 'mssql.quorum.state.[{#CLUSTER_NAME}]'
              description: |
                State of the WSFC quorum, one of:
                0 = Unknown quorum state
                1 = Normal quorum
                2 = Forced quorum
              valuemap:
                name: 'MSSQL Quorum state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.cluster_name==''{#CLUSTER_NAME}'')].quorum_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.quorum.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: cluster-name
                  value: '{#CLUSTER_NAME}'
                - tag: component
                  value: quorum
            - uuid: 1a00d48af79340478b359a958cb78e3f
              name: 'MSSQL Cluster ''{#CLUSTER_NAME}'': Quorum type'
              type: DEPENDENT
              key: 'mssql.quorum.type.[{#CLUSTER_NAME}]'
              description: |
                Type of quorum used by this WSFC cluster, one of:
                0 = Node Majority. This quorum configuration can sustain failures of half the nodes (rounding up) minus one.
                1 = Node and Disk Majority. If the disk witness remains on line, this quorum configuration can sustain failures of half the nodes (rounding up).
                2 = Node and File Share Majority. This quorum configuration works in a similar way to Node and Disk Majority, but uses a file-share witness instead of a disk witness.
                3 = No Majority: Disk Only. If the quorum disk is online, this quorum configuration can sustain failures of all nodes except one.
                4 = Unknown Quorum. Unknown quorum for the cluster.
                5 = Cloud Witness. Cluster utilizes Microsoft Azure for quorum arbitration. If the cloud witness is available, the cluster can sustain the failure of half the nodes (rounding up).
              valuemap:
                name: 'MSSQL Quorum type'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.cluster_name==''{#CLUSTER_NAME}'')].quorum_type.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'mssql.quorum.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: cluster-name
                  value: '{#CLUSTER_NAME}'
                - tag: component
                  value: quorum
          master_item:
            key: 'mssql.quorum.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          lld_macro_paths:
            - lld_macro: '{#CLUSTER_NAME}'
              path: $.cluster_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: 57e6fe3d425d4d74a360f26bb5ff5e57
          name: 'Quorum members discovery'
          type: DEPENDENT
          key: mssql.quorum.member.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CLUSTER_NAME}'
                value: ^.+$
              - macro: '{#MEMBER_NAME}'
                value: '{$MSSQL.QUORUM.MEMBER.DISCOVERY.NAME.MATCHES}'
              - macro: '{#MEMBER_NAME}'
                value: '{$MSSQL.QUORUM.MEMBER.DISCOVERY.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery of the quorum members of the WSFC cluster.'
          item_prototypes:
            - uuid: 6fec1fe9856c4b7eb1f7446e01a75ce5
              name: 'MSSQL Cluster member ''{#MEMBER_NAME}'': Member state'
              type: DEPENDENT
              key: 'mssql.quorum_members.member_state.[{#MEMBER_NAME}]'
              description: |
                The member state, one of:
                0 = Offline
                1 = Online
              valuemap:
                name: 'MSSQL Quorum members state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.member_name==''{#MEMBER_NAME}'')].member_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.quorum.member.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: 'quorum members'
                - tag: quorum-members-name
                  value: '{#MEMBER_NAME}'
            - uuid: d8dd85b6fc764ba4abc4d5cff0cefced
              name: 'MSSQL Cluster member ''{#MEMBER_NAME}'': Member type'
              type: DEPENDENT
              key: 'mssql.quorum_members.member_type.[{#MEMBER_NAME}]'
              description: |
                The type of member, one of:
                0 = WSFC node
                1 = Disk witness
                2 = File share witness
                3 = Cloud Witness
              valuemap:
                name: 'MSSQL Quorum members type'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.member_name==''{#MEMBER_NAME}'')].member_type.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'mssql.quorum.member.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: 'quorum members'
                - tag: quorum-members-name
                  value: '{#MEMBER_NAME}'
            - uuid: 87154fcf731b461b94e816ce58ef44ac
              name: 'MSSQL Cluster member ''{#MEMBER_NAME}'': Number of quorum votes'
              type: DEPENDENT
              key: 'mssql.quorum_members.number_of_quorum_votes.[{#MEMBER_NAME}]'
              description: 'Number of quorum votes possessed by this quorum member.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.member_name==''{#MEMBER_NAME}'')].number_of_quorum_votes.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'mssql.quorum.member.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: 'quorum members'
                - tag: quorum-members-name
                  value: '{#MEMBER_NAME}'
          master_item:
            key: 'mssql.quorum.member.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          lld_macro_paths:
            - lld_macro: '{#CLUSTER_NAME}'
              path: $.cluster_name
            - lld_macro: '{#MEMBER_NAME}'
              path: $.member_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: f72e7102f3314225b298a44332361aea
          name: 'Replication discovery'
          type: DEPENDENT
          key: mssql.replica.discovery
          description: 'Discovery of the database replicas.'
          item_prototypes:
            - uuid: a685cc983de040a6a6456d0568b74492
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Connected state'
              type: DEPENDENT
              key: 'mssql.replica.connected_state["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Whether a secondary replica is currently connected to the primary replica:
                0 = Disconnected. The response of an availability replica to the "Disconnected" state depends on its role:
                On the primary replica, if a secondary replica is disconnected, its secondary databases are marked as "Not synchronized" on the primary replica, which waits for the secondary to reconnect;
                On a secondary replica, upon detecting that it is disconnected, the secondary replica attempts to reconnect to the primary replica.
                1 = Connected. Each primary replica tracks the connection state for every secondary replica in the same availability group. Secondary replicas track the connection state of only the primary replica.
              valuemap:
                name: 'MSSQL AG Connected state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].connected_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.replica.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
            - uuid: 8dd557f2254a43adb8d56864d8910c11
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Is local'
              type: DEPENDENT
              key: 'mssql.replica.is_local["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Whether the replica is local:
                0 = Indicates a remote secondary replica in an availability group whose primary replica is hosted by the local server instance. This value occurs only on the primary replica location.
                1 = Indicates a local replica. On secondary replicas, this is the only available value for the availability group to which the replica belongs.
              valuemap:
                name: 'MSSQL - Yes / No'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].is_local.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.replica.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
            - uuid: 1f6c0f9e0757405eb172fa97f8dfe990
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Join state'
              type: DEPENDENT
              key: 'mssql.replica.join_state["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                0 = Not joined
                1 = Joined, standalone instance
                2 = Joined, failover cluster instance
              valuemap:
                name: 'MSSQL AG Join state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].join_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.replica.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
            - uuid: bc71481dd6b047679946f8488dd844f7
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Operational state'
              type: DEPENDENT
              key: 'mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Current operational state of the replica:
                0 = Pending failover
                1 = Pending
                2 = Online
                3 = Offline
                4 = Failed
                5 = Failed, no quorum
                6 = Not local
              valuemap:
                name: 'MSSQL AG Operational state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].operational_state.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.replica.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
              trigger_prototypes:
                - uuid: 7a05f5f0393f442d8e5d78669e9dd8cb
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=0 or last(/MSSQL by Zabbix agent 2/mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=1 or last(/MSSQL by Zabbix agent 2/mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=3'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is {ITEM.VALUE}'
                  priority: WARNING
                  description: 'The operational state of the replica in a given availability group is "Pending" or "Offline".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: availability
                - uuid: 5f67fcecd9864c5a97c0bb7c8281cd81
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=4'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is {ITEM.VALUE}'
                  priority: AVERAGE
                  description: 'The operational state of the replica in a given availability group is "Failed".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: availability
                - uuid: 7e387d698f214c458a6e45d64191185e
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.replica.operational_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=5'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is {ITEM.VALUE}'
                  priority: HIGH
                  description: 'The operational state of the replica in a given availability group is "Failed, no quorum".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: availability
            - uuid: a1ae4502e4a445f7801ba8283124e480
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Recovery health'
              type: DEPENDENT
              key: 'mssql.replica.recovery_health["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Rollup of the "database_state" column of the `sys.dm_hadr_database_replica_states` dynamic management view:
                0 = In progress. At least one joined database has a database state other than "Online" (database_state is not "0").
                1 = Online. All the joined databases have a database state of "Online" (database_state is "0").
              valuemap:
                name: 'MSSQL AG Recovery health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].recovery_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.replica.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
              trigger_prototypes:
                - uuid: 9c5f393288114e1081055f18c136dd07
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.replica.recovery_health["{#GROUP_NAME}_{#REPLICA_NAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} Recovery in progress'
                  priority: INFO
                  description: 'At least one joined database has a database state other than "Online".'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: notice
            - uuid: 50afa669369d4a5e936748aee07e76f0
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Role'
              type: DEPENDENT
              key: 'mssql.replica.role["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Current Always On availability group role of a local replica or a connected remote replica:
                0 = Resolving
                1 = Primary
                2 = Secondary
              valuemap:
                name: 'MSSQL AG Role'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].role.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.replica.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
            - uuid: 6a1abecd7c0044dd82442b30df3b4eae
              name: 'MSSQL AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': Sync health'
              type: DEPENDENT
              key: 'mssql.replica.synchronization_health["{#GROUP_NAME}_{#REPLICA_NAME}"]'
              description: |
                Reflects a rollup of the database synchronization state (synchronization_state) of all joined availability databases (also known as replicas) and the availability mode of the replica (synchronous-commit or asynchronous-commit mode). The rollup will reflect the least healthy accumulated state of the databases on the replica:
                0 = Not healthy. At least one joined database is in the "Not synchronizing" state.
                1 = Partially healthy. Some replicas are not in the target synchronization state: synchronous-commit replicas should be synchronized, and asynchronous-commit replicas should be synchronizing.
                2 = Healthy. All replicas are in the target synchronization state: synchronous-commit replicas are synchronized, and asynchronous-commit replicas are synchronizing.
              valuemap:
                name: 'MSSQL AG Synchronization health'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.replica_name==''{#REPLICA_NAME}'' && @.group_name==''{#GROUP_NAME}'')].synchronization_health.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mssql.replica.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: component
                  value: replica
                - tag: replica
                  value: '{#REPLICA_NAME}'
              trigger_prototypes:
                - uuid: 57aef51f42cd4e40a1041bb6862fde27
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.replica.synchronization_health["{#GROUP_NAME}_{#REPLICA_NAME}"])=0'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is Not healthy'
                  priority: AVERAGE
                  description: 'At least one joined database is in the "Not synchronizing" state.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: availability
                - uuid: e2ce3d5eb0174f1789ed01f3516f25dd
                  expression: 'last(/MSSQL by Zabbix agent 2/mssql.replica.synchronization_health["{#GROUP_NAME}_{#REPLICA_NAME}"])=1'
                  name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is Partially healthy'
                  priority: WARNING
                  description: 'Some replicas are not in the target synchronization state: synchronous-commit replicas should be synchronized, and asynchronous-commit replicas should be synchronizing.'
                  tags:
                    - tag: availability-group
                      value: '{#GROUP_NAME}'
                    - tag: replica
                      value: '{#REPLICA_NAME}'
                    - tag: scope
                      value: availability
          trigger_prototypes:
            - uuid: b6e37290b6b44d2888bdbfe53a949b63
              expression: 'last(/MSSQL by Zabbix agent 2/mssql.replica.connected_state["{#GROUP_NAME}_{#REPLICA_NAME}"])=0 and last(/MSSQL by Zabbix agent 2/mssql.replica.role["{#GROUP_NAME}_{#REPLICA_NAME}"])=2'
              name: 'MSSQL: AG ''{#GROUP_NAME}'' Replica ''{#REPLICA_NAME}'': {#REPLICA_NAME} is disconnected'
              priority: WARNING
              description: |
                The response of an availability replica to the "Disconnected" state depends on its role:
                On the primary replica, if a secondary replica is disconnected, its secondary databases are marked as "Not synchronized" on the primary replica, which waits for the secondary to reconnect;
                On a secondary replica, upon detecting that it is disconnected, the secondary replica attempts to reconnect to the primary replica.
              tags:
                - tag: availability-group
                  value: '{#GROUP_NAME}'
                - tag: replica
                  value: '{#REPLICA_NAME}'
                - tag: scope
                  value: availability
          master_item:
            key: 'mssql.replica.get["{$MSSQL.URI}","{$MSSQL.USER}","{$MSSQL.PASSWORD}"]'
          lld_macro_paths:
            - lld_macro: '{#GROUP_NAME}'
              path: $.group_name
            - lld_macro: '{#REPLICA_NAME}'
              path: $.replica_name
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: mssql
      macros:
        - macro: '{$MSSQL.AVERAGE_WAIT_TIME.MAX}'
          value: '500'
          description: 'The maximum average wait time, in milliseconds - for the trigger expression.'
          config:
            type: TEXT
            priority: '16'
            section_name: Thresholds
            label: 'Average wait time threshold'
            description: 'Threshold of the maximum average wait time in milliseconds. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.BACKUP_DIFF.CRIT}'
          value: 6d
          description: 'The maximum of days without a differential backup - for the High trigger expression.'
          config:
            type: TEXT
            priority: '27'
            section_name: Thresholds
            label: 'Critical differential backup threshold'
            description: 'Critical threshold of the maximum days without a differential backup.'
        - macro: '{$MSSQL.BACKUP_DIFF.USED}'
          value: '1'
          description: 'The flag for checking the age of a differential backup. If set to a value other than "1", the trigger expression for the differential backup age will not fire. Can be used with context for database name.'
          config:
            type: CHECKBOX
            priority: '35'
            section_name: Other
            label: 'Monitoring of differential backup'
            description: 'Whether it is necessary to monitor of differential backup.'
            options:
              - checked: '1'
                unchecked: '0'
        - macro: '{$MSSQL.BACKUP_DIFF.WARN}'
          value: 3d
          description: 'The maximum of days without a differential backup - for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '26'
            section_name: Thresholds
            label: 'Warning differential backup threshold'
            description: 'Warning threshold of the maximum days without a differential backup.'
        - macro: '{$MSSQL.BACKUP_DURATION.WARN}'
          value: 1h
          description: 'The maximum job duration - for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '32'
            section_name: Thresholds
            label: 'Job duration threshold'
            description: 'Threshold of the maximum job duration.'
        - macro: '{$MSSQL.BACKUP_FULL.CRIT}'
          value: 10d
          description: 'The maximum of days without a full backup - for the High trigger expression.'
          config:
            type: TEXT
            priority: '29'
            section_name: Thresholds
            label: 'Critical full backup threshold'
            description: 'Critical threshold of the maximum days without a full backup.'
        - macro: '{$MSSQL.BACKUP_FULL.USED}'
          value: '1'
          description: 'The flag for checking the age of a full backup. If set to a value other than "1", the trigger expression for the full backup age will not fire. Can be used with context for database name.'
          config:
            type: CHECKBOX
            priority: '33'
            section_name: Other
            label: 'Monitoring of full backup'
            description: 'Whether it is necessary to monitor of full backup.'
            options:
              - checked: '1'
                unchecked: '0'
        - macro: '{$MSSQL.BACKUP_FULL.WARN}'
          value: 9d
          description: 'The maximum of days without a full backup - for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '28'
            section_name: Thresholds
            label: 'Warning full backup threshold'
            description: 'Warning threshold of the maximum days without a full backup.'
        - macro: '{$MSSQL.BACKUP_LOG.CRIT}'
          value: 8h
          description: 'The maximum of days without a log backup - for the High trigger expression.'
          config:
            type: TEXT
            priority: '31'
            section_name: Thresholds
            label: 'Critical log backup threshold'
            description: 'Critical threshold of the maximum days without a log backup.'
        - macro: '{$MSSQL.BACKUP_LOG.USED}'
          value: '1'
          description: 'The flag for checking the age of a log backup. If set to a value other than "1", the trigger expression for the log backup age will not fire. Can be used with context for database name.'
          config:
            type: CHECKBOX
            priority: '34'
            section_name: Other
            label: 'Monitoring of log backup'
            description: 'Whether it is necessary to monitor of log backup.'
            options:
              - checked: '1'
                unchecked: '0'
        - macro: '{$MSSQL.BACKUP_LOG.WARN}'
          value: 4h
          description: 'The maximum of days without a log backup - for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '30'
            section_name: Thresholds
            label: 'Warning log backup threshold'
            description: 'Warning threshold of the maximum days without a log backup.'
        - macro: '{$MSSQL.BUFFER_CACHE_RATIO.MIN.CRIT}'
          value: '30'
          description: 'The minimum buffer cache hit ratio, in percent - for the High trigger expression.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'Critical buffer cache hit ratio threshold'
            description: 'Critical threshold for the minimum percentage of buffer cache hit ratio. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.BUFFER_CACHE_RATIO.MIN.WARN}'
          value: '50'
          description: 'The minimum buffer cache hit ratio, in percent - for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Warning buffer cache hit ratio threshold'
            description: 'Warning threshold for the minimum percentage of buffer cache hit ratio. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.DBNAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in database discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '36'
            section_name: Filters
            label: 'Include database filter'
            description: 'Regex string to include discovered database by its name.'
        - macro: '{$MSSQL.DBNAME.NOT_MATCHES}'
          value: master|tempdb|model|msdb
          description: 'This macro is used in database discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '37'
            section_name: Filters
            label: 'Exclude database filter'
            description: 'Regex string to exclude discovered database by its name.'
        - macro: '{$MSSQL.DEADLOCKS.MAX}'
          value: '1'
          description: 'The maximum deadlocks per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '19'
            section_name: Thresholds
            label: 'Deadlocks per second threshold'
            description: 'Threshold of the maximum number of deadlocks per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.FREE_LIST_STALLS.MAX}'
          value: '2'
          description: 'The maximum free list stalls per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'Free list stalls per second threshold'
            description: 'Threshold of the maximum number of free list stalls per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.HOST}'
          value: localhost
          description: 'The hostname or IP address of the MSSQL instance.'
          config:
            type: TEXT
            priority: '4'
            label: 'MSSQL address'
            description: 'Hostname or IP address of the MSSQL instance.'
        - macro: '{$MSSQL.JOB.MATCHES}'
          value: '.*'
          description: 'This macro is used in job discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '38'
            section_name: Filters
            label: 'Include job filter'
            description: 'Regex string to include discovered job by its name.'
        - macro: '{$MSSQL.JOB.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in job discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '39'
            section_name: Filters
            label: 'Exclude job filter'
            description: 'Regex string to exclude discovered job by its name.'
        - macro: '{$MSSQL.LAZY_WRITES.MAX}'
          value: '20'
          description: 'The maximum lazy writes per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '12'
            section_name: Thresholds
            label: 'Lazy writes per second threshold'
            description: 'Threshold of the maximum number of lazy writes per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.LOCK_REQUESTS.MAX}'
          value: '1000'
          description: 'The maximum lock requests per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '17'
            section_name: Thresholds
            label: 'Lock requests per second threshold'
            description: 'Threshold of the maximum number of lock requests per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.LOCK_TIMEOUTS.MAX}'
          value: '1'
          description: 'The maximum lock timeouts per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '18'
            section_name: Thresholds
            label: 'Lock timeouts per second threshold'
            description: 'Threshold of the maximum number of lock timeouts per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.LOG_FLUSH_WAITS.MAX}'
          value: '1'
          description: 'The maximum log flush waits per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '20'
            section_name: Thresholds
            label: 'Log flush waits per second threshold'
            description: 'Threshold for the maximum number of log flush waits per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.LOG_FLUSH_WAIT_TIME.MAX}'
          value: '1'
          description: 'The maximum log flush wait time, in milliseconds - for the trigger expression.'
          config:
            type: TEXT
            priority: '21'
            section_name: Thresholds
            label: 'Log flush wait time threshold'
            description: 'Threshold of the maximum log flush wait time in milliseconds. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PAGE_LIFE_EXPECTANCY.MIN}'
          value: '300'
          description: 'The minimum page life expectancy - for the trigger expression.'
          config:
            type: TEXT
            priority: '13'
            section_name: Thresholds
            label: 'Page life expectancy threshold'
            description: 'Threshold of the minimum page life expectancy. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PAGE_READS.MAX}'
          value: '90'
          description: 'The maximum page reads per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '14'
            section_name: Thresholds
            label: 'Page reads per second threshold'
            description: 'Threshold of the maximum number of page reads per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PAGE_WRITES.MAX}'
          value: '90'
          description: 'The maximum page writes per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '15'
            section_name: Thresholds
            label: 'Page writes per second threshold'
            description: 'Threshold of the maximum number of page writes per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PASSWORD}'
          description: 'MSSQL user password.'
          config:
            type: TEXT
            priority: '3'
            label: 'MSSQL password'
            required: 'YES'
        - macro: '{$MSSQL.PERCENT_COMPILATIONS.MAX}'
          value: '10'
          description: 'The maximum percentage of Transact-SQL compilations - for the trigger expression.'
          config:
            type: TEXT
            priority: '23'
            section_name: Thresholds
            label: 'Transact-SQL compilations threshold'
            description: 'Threshold for the maximum percentage of Transact-SQL compilations. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PERCENT_LOG_USED.MAX}'
          value: '80'
          description: 'The maximum percentage of log used - for the trigger expression.'
          config:
            type: TEXT
            priority: '22'
            section_name: Thresholds
            label: 'Log used threshold'
            description: 'Threshold for the maximum percentage of log used. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PERCENT_READAHEAD.MAX}'
          value: '20'
          description: 'The maximum percentage of pages read per second in anticipation of use - for the trigger expression.'
          config:
            type: TEXT
            priority: '25'
            section_name: Thresholds
            label: 'Threshold of pages read per second in anticipation of use'
            description: 'Threshold of the maximum percentage of pages read per second in anticipation of use. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PERCENT_RECOMPILATIONS.MAX}'
          value: '10'
          description: 'The maximum percentage of Transact-SQL recompilations - for the trigger expression.'
          config:
            type: TEXT
            priority: '24'
            section_name: Thresholds
            label: 'Transact-SQL recompilations threshold'
            description: 'Threshold for the maximum percentage of Transact-SQL recompilations. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.PORT}'
          value: '1433'
          description: 'MSSQL TCP port.'
          config:
            type: TEXT
            priority: '5'
            label: 'MSSQL TCP port'
            description: 'Port of the MSSQL instance. In the range from 1 to 65535 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.QUORUM.MEMBER.DISCOVERY.NAME.MATCHES}'
          value: '.*'
          description: 'Filter to include discovered quorum member by name.'
          config:
            type: TEXT
            priority: '40'
            section_name: Filters
            label: 'Include quorum member filter'
            description: 'Regex string to include discovered quorum member by name.'
        - macro: '{$MSSQL.QUORUM.MEMBER.DISCOVERY.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discovered quorum member by name.'
          config:
            type: TEXT
            priority: '41'
            section_name: Filters
            label: 'Exclude quorum member filter'
            description: 'Regex string to exclude discovered quorum member by name.'
        - macro: '{$MSSQL.URI}'
          description: 'Connection string.'
          config:
            type: TEXT
            priority: '1'
            label: 'MSSQL URI'
            description: 'Connection string for the MSSQL instance.'
            required: 'YES'
        - macro: '{$MSSQL.USER}'
          description: 'MSSQL username.'
          config:
            type: TEXT
            priority: '2'
            label: 'MSSQL user'
            required: 'YES'
        - macro: '{$MSSQL.WORKTABLES_FROM_CACHE_RATIO.MIN.CRIT}'
          value: '90'
          description: 'The minimum percentage of work tables from the cache ratio - for the High trigger expression.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Percentage of work tables from the cache ratio threshold'
            description: 'Threshold for the minimum percentage of work tables from the cache ratio. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.WORK_FILES.MAX}'
          value: '20'
          description: 'The maximum number of work files created per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '6'
            section_name: Thresholds
            label: 'Work files created per second threshold'
            description: 'Threshold of the maximum number of work files created per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MSSQL.WORK_TABLES.MAX}'
          value: '20'
          description: 'The maximum number of work tables created per second - for the trigger expression.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Work files tables per second threshold'
            description: 'Threshold of the maximum number of work tables created per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
      dashboards:
        - uuid: 699c7aa81a4b476abb938f3db0debf73
          name: 'MSSQL: Overview'
          pages:
            - name: Main
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Errors'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Server memory'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Waits per second'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Database pages'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graph
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Transactions'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graph
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Pages'
                    - type: STRING
                      name: reference
                      value: AAAAK
                - type: graph
                  'y': '30'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Memory grants outstanding and pending'
                    - type: STRING
                      name: reference
                      value: AAAAM
                - type: graph
                  'y': '35'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Access methods'
                    - type: STRING
                      name: reference
                      value: AAAAO
                - type: graph
                  'y': '40'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Logins per second and Logouts per second'
                    - type: STRING
                      name: reference
                      value: AAAAQ
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Locks'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Memory/cache load'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Wait times'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Cache objects'
                    - type: STRING
                      name: reference
                      value: AAAAH
                - type: graph
                  x: '36'
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Compilations'
                    - type: STRING
                      name: reference
                      value: AAAAJ
                - type: graph
                  x: '36'
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Page life expectancy'
                    - type: STRING
                      name: reference
                      value: AAAAL
                - type: graph
                  x: '36'
                  'y': '30'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Processes blocked'
                    - type: STRING
                      name: reference
                      value: AAAAN
                - type: graph
                  x: '36'
                  'y': '35'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'MSSQL: Auto-params'
                    - type: STRING
                      name: reference
                      value: AAAAP
            - name: Databases
              widgets:
                - type: graphprototype
                  width: '36'
                  height: '15'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'DB ''{#DBNAME}'': Size'
                    - type: STRING
                      name: reference
                      value: AAAAR
                    - type: INTEGER
                      name: rows
                      value: '3'
                - type: graphprototype
                  x: '36'
                  width: '36'
                  height: '15'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'MSSQL by Zabbix agent 2'
                        name: 'DB ''{#DBNAME}'': Log size'
                    - type: STRING
                      name: reference
                      value: AAAAS
                    - type: INTEGER
                      name: rows
                      value: '3'
      valuemaps:
        - uuid: 0d7dbd62613540cc8dd70d2f0ec76db6
          name: 'MSSQL - Yes / No'
          mappings:
            - value: '0'
              newvalue: 'No'
            - value: '1'
              newvalue: 'Yes'
        - uuid: 1f962ea838d640d5905ae14d66826239
          name: 'MSSQL AG Connected state'
          mappings:
            - value: '0'
              newvalue: Disconnected
            - value: '1'
              newvalue: Connected
        - uuid: 034a175b7fba4e4d8e85806c8f801f18
          name: 'MSSQL AG Join state'
          mappings:
            - value: '0'
              newvalue: 'Not joined'
            - value: '1'
              newvalue: 'Joined, standalone instance'
            - value: '2'
              newvalue: 'Joined, failover cluster instance'
        - uuid: fbbaea2f75f94b7ba0bb2ed2756e2593
          name: 'MSSQL AG Operational state'
          mappings:
            - value: '0'
              newvalue: 'Pending failover'
            - value: '1'
              newvalue: Pending
            - value: '2'
              newvalue: Online
            - value: '3'
              newvalue: Offline
            - value: '4'
              newvalue: Failed
            - value: '5'
              newvalue: 'Failed, no quorum'
            - value: '6'
              newvalue: 'Replica is not local'
        - uuid: c90a7f77957a40c8bb6c9370ff1f63d1
          name: 'MSSQL AG Recovery health'
          mappings:
            - value: '0'
              newvalue: 'In progress'
            - value: '1'
              newvalue: Online
            - value: '2'
              newvalue: 'Replica is not local'
        - uuid: b07e0cd2c7fd4411b16305141058c9d7
          name: 'MSSQL AG Role'
          mappings:
            - value: '0'
              newvalue: Resolving
            - value: '1'
              newvalue: Primary
            - value: '2'
              newvalue: Secondary
        - uuid: dd1d46bfb14946769dc929ae1947a328
          name: 'MSSQL AG Synchronization health'
          mappings:
            - value: '0'
              newvalue: 'Not healthy'
            - value: '1'
              newvalue: 'Partially healthy'
            - value: '2'
              newvalue: Healthy
        - uuid: eeca1ed2c3cb4624b045b9ba0007f1a6
          name: 'MSSQL DB state'
          mappings:
            - value: '0'
              newvalue: ONLINE
            - value: '1'
              newvalue: RESTORING
            - value: '2'
              newvalue: RECOVERING
            - value: '3'
              newvalue: RECOVERY_PENDING
            - value: '4'
              newvalue: SUSPECT
            - value: '5'
              newvalue: EMERGENCY
            - value: '6'
              newvalue: OFFLINE
            - value: '7'
              newvalue: COPYING
            - value: '10'
              newvalue: OFFLINE_SECONDARY
        - uuid: bc4b734c0c3e4f508323a8880a9b27db
          name: 'MSSQL Job Run Status'
          mappings:
            - value: '0'
              newvalue: Failed
            - value: '1'
              newvalue: Succeeded
            - value: '2'
              newvalue: Retry
            - value: '3'
              newvalue: Canceled
            - value: '4'
              newvalue: Running
            - value: '5'
              newvalue: Unknown
        - uuid: 09480e835f474f22ba463b7c6b486de1
          name: 'MSSQL Mirroring Role'
          mappings:
            - value: '0'
              newvalue: 'Database is inaccessible or is not mirrored'
            - value: '1'
              newvalue: Principal
            - value: '2'
              newvalue: Mirror
        - uuid: 6fd710f80063456483f47dab9fdab3c3
          name: 'MSSQL Mirroring State'
          mappings:
            - value: '0'
              newvalue: Suspended
            - value: '1'
              newvalue: 'Disconnected from the other partner'
            - value: '2'
              newvalue: Synchronizing
            - value: '3'
              newvalue: 'Pending failover'
            - value: '4'
              newvalue: Synchronized
            - value: '5'
              newvalue: 'The partners are not synchronized. Failover is not possible now.'
            - value: '6'
              newvalue: 'The partners are synchronized. Failover is potentially possible.'
            - value: '7'
              newvalue: 'Database is inaccessible or is not mirrored'
        - uuid: 300744b8bf494bc09cae58f1366e8043
          name: 'MSSQL Quorum members state'
          mappings:
            - value: '0'
              newvalue: Offline
            - value: '1'
              newvalue: Online
        - uuid: 38b1c1c9183f450cb3256fefaa8ae24a
          name: 'MSSQL Quorum members type'
          mappings:
            - value: '0'
              newvalue: 'WSFC node'
            - value: '1'
              newvalue: 'Disk witness'
            - value: '2'
              newvalue: 'File share witness'
            - value: '3'
              newvalue: 'Cloud Witness'
        - uuid: 047cb848051f4e85a1f45664fd51255b
          name: 'MSSQL Quorum state'
          mappings:
            - value: '0'
              newvalue: 'Unknown quorum state'
            - value: '1'
              newvalue: 'Normal quorum'
            - value: '2'
              newvalue: 'Forced quorum'
        - uuid: 2697dc5e3d5e462aac7951844a9fa76c
          name: 'MSSQL Quorum type'
          mappings:
            - value: '0'
              newvalue: 'Node Majority'
            - value: '1'
              newvalue: 'Node and Disk Majority'
            - value: '2'
              newvalue: 'Node and File Share Majority'
            - value: '3'
              newvalue: 'No Majority: Disk Only'
            - value: '4'
              newvalue: 'Unknown Quorum'
            - value: '5'
              newvalue: 'Cloud Witness'
        - uuid: 1002338ba75c49f89ce5c27872818ff3
          name: 'MSSQL Recovery model'
          mappings:
            - value: '1'
              newvalue: FULL
            - value: '2'
              newvalue: BULK_LOGGED
            - value: '3'
              newvalue: SIMPLE
        - uuid: 8800c652dc154231b40e996b39c7c2dd
          name: 'MSSQL Safety level'
          mappings:
            - value: '0'
              newvalue: 'Unknown state'
            - value: '1'
              newvalue: 'Off [asynchronous]'
            - value: '2'
              newvalue: 'Full [synchronous]'
            - value: '3'
              newvalue: 'Database is inaccessible or is not mirrored'
        - uuid: 0be116423b4949959053d581cafa096c
          name: 'MSSQL Witness state'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Connected
            - value: '2'
              newvalue: Disconnected
            - value: '3'
              newvalue: 'No witness exists'
        - uuid: faafc4168c5a4eb09d20ab4168fbbc9e
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: e19c120027e04da69b130e0f6cea29fc
      template: 'MySQL by ODBC'
      name: 'MySQL by ODBC'
      description: |
        Requirements for template operation:
        1. Create a MySQL user for monitoring. For example:
        
        CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
        
        For more information please read the MySQL documentation https://dev.mysql.com/doc/refman/8.0/en/grant.html.
        
        NOTE: In order to collect replication metrics, MariaDB Enterprise Server 10.5.8-5 and above and MariaDB Community Server 10.5.9 and above require the SLAVE MONITOR privilege to be set for the monitoring user:
        
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW,SLAVE MONITOR ON *.* TO 'zbx_monitor'@'%';
        
        For more information please read the MariaDB documentation https://mariadb.com/docs/server/ref/mdb/privileges/SLAVE_MONITOR/
        
        2. Set the user name and password in the host macros ({$MYSQL.USER} and {$MYSQL.PASSWORD}).
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384189-discussion-thread-for-official-zabbix-template-db-mysql
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        1. Create a MySQL user for monitoring (`<password>` at your discretion):
        
        ```text
        CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
        ```
        
        For more information, please see MySQL documentation https://dev.mysql.com/doc/refman/8.0/en/grant.html
        
        **NOTE:** In order to collect replication metrics, MariaDB Enterprise Server 10.5.8-5 and above and MariaDB Community Server 10.5.9 and above require the `SLAVE MONITOR` privilege to be set for the monitoring user:
        
        ```text
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW,SLAVE MONITOR ON *.* TO 'zbx_monitor'@'%';
        ```
        
        For more information please read the MariaDB documentation https://mariadb.com/docs/server/ref/mdb/privileges/SLAVE_MONITOR/
        
        2. Set the username and password in the `MySQL user` and `MySQL password` host wizard configuration fields.
      vendor:
        name: Zabbix
        version: 7.4-3
      groups:
        - name: Templates/Databases
      items:
        - uuid: 70491bf6b6af401c9dfb10c0cbfddee1
          name: 'Get database'
          type: ODBC
          key: 'db.odbc.get[get_database,"{$MYSQL.DSN}"]'
          delay: 1h
          history: '0'
          value_type: TEXT
          params: 'show databases'
          username: '{$MYSQL.USER}'
          password: '{$MYSQL.PASSWORD}'
          description: 'Used for scanning databases in DBMS.'
          tags:
            - tag: component
              value: raw
        - uuid: e389af9f1d134e028e3b637544c8a265
          name: 'Get replication'
          type: ODBC
          key: 'db.odbc.get[get_replication,"{$MYSQL.DSN}"]'
          history: '0'
          value_type: TEXT
          params: 'show slave status'
          username: '{$MYSQL.USER}'
          password: '{$MYSQL.PASSWORD}'
          description: 'Gets replication status information.'
          tags:
            - tag: component
              value: raw
        - uuid: 72e0f88741d746bf88e8951ef69681f9
          name: 'Get status variables'
          type: ODBC
          key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          history: '0'
          value_type: TEXT
          params: 'show global status'
          username: '{$MYSQL.USER}'
          password: '{$MYSQL.PASSWORD}'
          description: 'Gets server global status information.'
          tags:
            - tag: component
              value: raw
        - uuid: 5b7c14e38799427cb6520f47bf8afe6c
          name: Status
          type: ODBC
          key: 'db.odbc.select[ping,"{$MYSQL.DSN}"]'
          params: 'select "1"'
          username: '{$MYSQL.USER}'
          password: '{$MYSQL.PASSWORD}'
          description: 'MySQL server status.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: e664e41d7b4f4336a3e5ef4720f6ee41
              expression: 'last(/MySQL by ODBC/db.odbc.select[ping,"{$MYSQL.DSN}"])=0'
              name: 'MySQL: Service is down'
              priority: HIGH
              description: 'MySQL is down.'
              tags:
                - tag: scope
                  value: availability
        - uuid: b9fb80ca366e4d33801472bcd013f881
          name: Version
          type: ODBC
          key: 'db.odbc.select[version,"{$MYSQL.DSN}"]'
          delay: 15m
          value_type: CHAR
          params: 'select version()'
          username: '{$MYSQL.USER}'
          password: '{$MYSQL.PASSWORD}'
          description: 'MySQL server version.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 4090a1d3d82d47ac85964baeae121b2b
              expression: 'last(/MySQL by ODBC/db.odbc.select[version,"{$MYSQL.DSN}"],#1)<>last(/MySQL by ODBC/db.odbc.select[version,"{$MYSQL.DSN}"],#2) and length(last(/MySQL by ODBC/db.odbc.select[version,"{$MYSQL.DSN}"]))>0'
              name: 'MySQL: Version has changed'
              event_name: 'MySQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              description: 'The MySQL version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 73235748ba4742c0aa3c4f29509a162d
          name: 'Aborted clients per second'
          type: DEPENDENT
          key: mysql.aborted_clients.rate
          value_type: FLOAT
          description: 'Number of connections that were aborted because the client died without closing the connection properly.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Aborted_clients'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: connections
        - uuid: b6185e79abd744f78ce579a83381ba87
          name: 'Aborted connections per second'
          type: DEPENDENT
          key: mysql.aborted_connects.rate
          value_type: FLOAT
          description: 'Number of failed attempts to connect to the MySQL server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Aborted_connects'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: 5934cb80f9c3442d978c63780b1ebc9f
              expression: 'min(/MySQL by ODBC/mysql.aborted_connects.rate,5m)>{$MYSQL.ABORTED_CONN.MAX.WARN}'
              name: 'MySQL: Server has aborted connections'
              event_name: 'MySQL: Server has aborted connections (over {$MYSQL.ABORTED_CONN.MAX.WARN} for 5m)'
              priority: AVERAGE
              description: 'The number of failed attempts to connect to the MySQL server is more than `{$MYSQL.ABORTED_CONN.MAX.WARN}` in the last 5 minutes.'
              dependencies:
                - name: 'MySQL: Refused connections'
                  expression: 'last(/MySQL by ODBC/mysql.connection_errors_max_connections.rate)>0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 9db77e72fd9d404a8e1fd4e72c92d75c
          name: 'Binlog cache disk use'
          type: DEPENDENT
          key: mysql.binlog_cache_disk_use
          value_type: FLOAT
          description: 'Number of transactions that used a temporary disk cache because they could not fit in the regular binary log cache, being larger than `binlog_cache_size`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Binlog_cache_disk_use'')].Value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 05e7e91206bb4138a945ea0de2d8c01d
          name: 'Buffer pool efficiency'
          type: CALCULATED
          key: mysql.buffer_pool_efficiency
          value_type: FLOAT
          units: '%'
          params: |
            100 - (last(//mysql.innodb_buffer_pool_reads) / 
            ( last(//mysql.innodb_buffer_pool_read_requests) + 
            ( last(//mysql.innodb_buffer_pool_read_requests) = 0 ) ) * 100 * 
            ( last(//mysql.innodb_buffer_pool_read_requests) > 0 ))
          description: 'The item shows how effectively the buffer pool is serving reads.'
          tags:
            - tag: component
              value: memory
        - uuid: ad5520e067ea405eb939d319fa9690e9
          name: 'Buffer pool utilization'
          type: CALCULATED
          key: mysql.buffer_pool_utilization
          value_type: FLOAT
          units: '%'
          params: |
            ( last(//mysql.innodb_buffer_pool_pages_total) - 
            last(//mysql.innodb_buffer_pool_pages_free) ) / 
            ( last(//mysql.innodb_buffer_pool_pages_total) + 
            ( last(//mysql.innodb_buffer_pool_pages_total) = 0 ) ) * 100 * 
            ( last(//mysql.innodb_buffer_pool_pages_total) > 0 )
          description: 'Ratio of used to total pages in the buffer pool.'
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: f4c2e4edf0c34bb1856ed392f2bc7c87
              expression: 'max(/MySQL by ODBC/mysql.buffer_pool_utilization,5m)<{$MYSQL.BUFF_UTIL.MIN.WARN}'
              name: 'MySQL: Buffer pool utilization is too low'
              event_name: 'MySQL: Buffer pool utilization is too low (less than {$MYSQL.BUFF_UTIL.MIN.WARN}% for 5m)'
              priority: WARNING
              description: 'The buffer pool utilization is less than `{$MYSQL.BUFF_UTIL.MIN.WARN}`% in the last 5 minutes. This means that there is a lot of unused RAM allocated for the buffer pool, which you can easily reallocate at the moment.'
              tags:
                - tag: scope
                  value: notice
        - uuid: f05d592e6ae74e64bc54c649418761a6
          name: 'Bytes received'
          type: DEPENDENT
          key: mysql.bytes_received.rate
          value_type: FLOAT
          units: Bps
          description: 'Number of bytes received from all clients.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Bytes_received'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: network
        - uuid: ce737bc186f24014a70c75da2386986d
          name: 'Bytes sent'
          type: DEPENDENT
          key: mysql.bytes_sent.rate
          value_type: FLOAT
          units: Bps
          description: 'Number of bytes sent to all clients.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Bytes_sent'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: network
        - uuid: a43ec23dad9345a5a1b0ff8bda12ed77
          name: 'Command Delete per second'
          type: DEPENDENT
          key: mysql.com_delete.rate
          value_type: FLOAT
          description: 'The `Com_delete` counter variable indicates the number of times the `DELETE` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Com_delete'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: operations
        - uuid: cd924e3b51074b3baf642a7aa1eeb474
          name: 'Command Insert per second'
          type: DEPENDENT
          key: mysql.com_insert.rate
          value_type: FLOAT
          description: 'The `Com_insert` counter variable indicates the number of times the `INSERT` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Com_insert'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: operations
        - uuid: 31e6372d1249442ab3ebdd993f397e26
          name: 'Command Select per second'
          type: DEPENDENT
          key: mysql.com_select.rate
          value_type: FLOAT
          description: 'The `Com_select` counter variable indicates the number of times the `SELECT` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Com_select'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: operations
        - uuid: 0f5f638777284093bcdc5f2dacc8e951
          name: 'Command Update per second'
          type: DEPENDENT
          key: mysql.com_update.rate
          value_type: FLOAT
          description: 'The `Com_update` counter variable indicates the number of times the `UPDATE` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Com_update'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: operations
        - uuid: fad5f4e1885341d1958f653afb85ff07
          name: 'Connections per second'
          type: DEPENDENT
          key: mysql.connections.rate
          value_type: FLOAT
          description: 'Number of connection attempts (successful or not) to the MySQL server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Connections'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 4b67e0e6291b4e0c841334ac052d7253
          name: 'Connection errors accept per second'
          type: DEPENDENT
          key: mysql.connection_errors_accept.rate
          value_type: FLOAT
          description: 'Number of errors that occurred during calls to `accept()` on the listening port.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Connection_errors_accept'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 76ad3a39e89e44daad08cc00174d4918
          name: 'Connection errors internal per second'
          type: DEPENDENT
          key: mysql.connection_errors_internal.rate
          value_type: FLOAT
          description: 'Number of refused connections due to internal server errors, for example, out of memory errors, or failed thread starts.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Connection_errors_internal'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 83dfb916c7674e1fbd300be444241e25
          name: 'Connection errors max connections per second'
          type: DEPENDENT
          key: mysql.connection_errors_max_connections.rate
          value_type: FLOAT
          description: 'Number of refused connections due to the `max_connections` limit being reached.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Connection_errors_max_connections'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: ac781c951ac0453a9c1008b2cf801518
              expression: 'last(/MySQL by ODBC/mysql.connection_errors_max_connections.rate)>0'
              name: 'MySQL: Refused connections'
              event_name: 'MySQL: Refused connections (max_connections limit reached)'
              priority: AVERAGE
              description: 'Number of refused connections due to the `max_connections` limit being reached.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 9be4cb9e209344d0869a56082d16ec53
          name: 'Connection errors peer address per second'
          type: DEPENDENT
          key: mysql.connection_errors_peer_address.rate
          value_type: FLOAT
          description: 'Number of errors while searching for the connecting client''s IP address.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Connection_errors_peer_address'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: connections
        - uuid: e50b9fea89cc440abc0155dc25346f05
          name: 'Connection errors select per second'
          type: DEPENDENT
          key: mysql.connection_errors_select.rate
          value_type: FLOAT
          description: 'Number of errors during calls to `select()` or `poll()` on the listening port. The client would not necessarily have been rejected in these cases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Connection_errors_select'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: connections
        - uuid: a82a7ada012141c6bdff63bc8d615786
          name: 'Connection errors tcpwrap per second'
          type: DEPENDENT
          key: mysql.connection_errors_tcpwrap.rate
          value_type: FLOAT
          description: 'Number of connections the libwrap library has refused.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Connection_errors_tcpwrap'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 84d748ab80444e10bdb60bcfbdfa850a
          name: 'Created tmp tables on disk per second'
          type: DEPENDENT
          key: mysql.created_tmp_disk_tables.rate
          value_type: FLOAT
          description: 'Number of internal on-disk temporary tables created by the server while executing statements.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Created_tmp_disk_tables'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: storage
            - tag: component
              value: tables
          triggers:
            - uuid: 8aec6a51fa3e4320b3c7c40858ac7f96
              expression: 'min(/MySQL by ODBC/mysql.created_tmp_disk_tables.rate,5m)>{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN}'
              name: 'MySQL: Number of on-disk temporary tables created per second is high'
              event_name: 'MySQL: Number of on-disk temporary tables created per second is high (over {$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: c5f2ae1ef46e4f65842ab4a31625906a
          name: 'Created tmp files on disk per second'
          type: DEPENDENT
          key: mysql.created_tmp_files.rate
          value_type: FLOAT
          description: 'How many temporary files `mysqld` has created.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Created_tmp_files'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: c1dbcf829bdf43fda3b4c2add576c8f0
              expression: 'min(/MySQL by ODBC/mysql.created_tmp_files.rate,5m)>{$MYSQL.CREATED_TMP_FILES.MAX.WARN}'
              name: 'MySQL: Number of temporary files created per second is high'
              event_name: 'MySQL: Number of temporary files created per second is high (over {$MYSQL.CREATED_TMP_FILES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 95fa4f4f1db44b2bb65889da246c03b5
          name: 'Created tmp tables on memory per second'
          type: DEPENDENT
          key: mysql.created_tmp_tables.rate
          value_type: FLOAT
          description: 'Number of internal temporary tables created by the server while executing statements.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Created_tmp_tables'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: tables
          triggers:
            - uuid: d65c3ec6cacd41c58f5e2b209ca5a810
              expression: 'min(/MySQL by ODBC/mysql.created_tmp_tables.rate,5m)>{$MYSQL.CREATED_TMP_TABLES.MAX.WARN}'
              name: 'MySQL: Number of internal temporary tables created per second is high'
              event_name: 'MySQL: Number of internal temporary tables created per second is high (over {$MYSQL.CREATED_TMP_TABLES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: e31f66bbc32b404c92debc4d9367162d
          name: 'InnoDB buffer pool pages free'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_pages_free
          description: 'The total size of the InnoDB buffer pool, in pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_buffer_pool_pages_free'')].Value.first()'
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 41019c084618404db183326c215d71f6
          name: 'InnoDB buffer pool pages total'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_pages_total
          description: 'The total size of the InnoDB buffer pool, in pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_buffer_pool_pages_total'')].Value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 441b718148974e289db93299f869feba
          name: 'InnoDB buffer pool reads'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_reads
          description: 'Number of logical reads that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_buffer_pool_reads'')].Value.first()'
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 22ae5946fc2548cf8eee39a57ce8512b
          name: 'InnoDB buffer pool reads per second'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_reads.rate
          value_type: FLOAT
          description: 'Number of logical reads per second that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_buffer_pool_reads'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 0a1775a7de33464e9ce8134950527021
          name: 'InnoDB buffer pool read requests'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_read_requests
          description: 'Number of logical read requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_buffer_pool_read_requests'')].Value.first()'
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 98684abf32e642bd8784e68e64357dc9
          name: 'InnoDB buffer pool read requests per second'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_read_requests.rate
          value_type: FLOAT
          description: 'Number of logical read requests per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_buffer_pool_read_requests'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 4e829cbb3cc2485dac2757867badd0f4
          name: 'Innodb buffer pool wait free'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_wait_free
          value_type: FLOAT
          description: 'Number of times InnoDB waited for a free page before reading or creating a page. Normally, writes to the InnoDB buffer pool happen in the background. When no clean pages are available, dirty pages are flushed first in order to free some up. This counts the numbers of wait for this operation to finish. If this value is not small, look at the increasing `innodb_buffer_pool_size`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_buffer_pool_wait_free'')].Value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 4680fd31a2514e3f827b0060a6d5bfc4
          name: 'Calculated value of innodb_log_file_size'
          type: CALCULATED
          key: mysql.innodb_log_file_size
          value_type: FLOAT
          params: '(last(//mysql.innodb_os_log_written) - last(//mysql.innodb_os_log_written,#1:now-1h)) / {$MYSQL.INNODB_LOG_FILES}'
          description: '`Innodb_log_file_size` is calculated as: (`innodb_os_log_written`-`innodb_os_log_written`(time shift -1h))/`{$MYSQL.INNODB_LOG_FILES}`. `Innodb_log_file_size` is the size in bytes of the each InnoDB redo log file in the log group. The combined size can be no more than 512 GB. Larger values mean less disk I/O due to less flushing checkpoint activity, but also slower recovery from a crash.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          tags:
            - tag: component
              value: system
        - uuid: 79218a1068394ce69dfc6eeb626e83bc
          name: 'Innodb number open files'
          type: DEPENDENT
          key: mysql.innodb_num_open_files
          value_type: FLOAT
          description: 'Number of open files held by InnoDB. InnoDB only.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_num_open_files'')].Value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: system
        - uuid: fc561c5392bb43a4842977bdf4b882a8
          name: 'Innodb log written'
          type: DEPENDENT
          key: mysql.innodb_os_log_written
          value_type: FLOAT
          units: B
          description: 'Number of bytes written to the InnoDB log.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_os_log_written'')].Value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: system
        - uuid: a62951afcfbd44e595a4d294b24056e5
          name: 'InnoDB row lock time'
          type: DEPENDENT
          key: mysql.innodb_row_lock_time
          value_type: FLOAT
          units: s
          description: 'The total time spent in acquiring row locks for InnoDB tables, in milliseconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_row_lock_time'')].Value.first()'
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: 22277695b7154c019a76ca730e68e833
          name: 'InnoDB row lock time max'
          type: DEPENDENT
          key: mysql.innodb_row_lock_time_max
          value_type: FLOAT
          units: s
          description: 'The maximum time to acquire a row lock for InnoDB tables, in milliseconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_row_lock_time_max'')].Value.first()'
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: 17c4270927a74d8388da8c25d9065556
          name: 'InnoDB row lock waits'
          type: DEPENDENT
          key: mysql.innodb_row_lock_waits
          description: 'Number of times operations on InnoDB tables had to wait for a row lock.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Innodb_row_lock_waits'')].Value.first()'
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: 6106ebf4cae842c1a5acc2f13518de4f
          name: 'Max used connections'
          type: DEPENDENT
          key: mysql.max_used_connections
          description: 'The maximum number of connections that have been in use simultaneously since the server start.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Max_used_connections'')].Value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 85e17b6b196e4916838e0318992fe33c
          name: 'Open tables'
          type: DEPENDENT
          key: mysql.open_tables
          value_type: FLOAT
          description: 'Number of tables that are open.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Open_tables'')].Value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: tables
        - uuid: c23ce7b2689745728465c5b405d7b3ba
          name: 'Open table definitions'
          type: DEPENDENT
          key: mysql.open_table_definitions
          value_type: FLOAT
          description: 'Number of cached table definitions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Open_table_definitions'')].Value.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: tables
        - uuid: 2f0ced88c4524455bf790b3bc6512d04
          name: 'Queries per second'
          type: DEPENDENT
          key: mysql.queries.rate
          value_type: FLOAT
          description: 'Number of statements executed by the server. This variable includes statements executed within stored programs, unlike the `Questions` variable.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Queries'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 8d0fc2eb0be94d68966e09fca88e8deb
          name: 'Questions per second'
          type: DEPENDENT
          key: mysql.questions.rate
          value_type: FLOAT
          description: 'Number of statements executed by the server. This includes only statements sent to the server by clients and not statements executed within stored programs, unlike the `Queries` variable.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Questions'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: queries
        - uuid: b0227399437f4219b65ab1511d5e67c6
          name: 'Slow queries per second'
          type: DEPENDENT
          key: mysql.slow_queries.rate
          value_type: FLOAT
          description: 'Number of queries that have taken more than `long_query_time` seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Slow_queries'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: queries
          triggers:
            - uuid: b981c7a2ffed4eddbc9f1d6913c2e4b0
              expression: 'min(/MySQL by ODBC/mysql.slow_queries.rate,5m)>{$MYSQL.SLOW_QUERIES.MAX.WARN}'
              name: 'MySQL: Server has slow queries'
              event_name: 'MySQL: Server has slow queries (over {$MYSQL.SLOW_QUERIES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The number of slow queries is more than `{$MYSQL.SLOW_QUERIES.MAX.WARN}` in the last 5 minutes.'
              tags:
                - tag: scope
                  value: performance
        - uuid: b675fd71138a4845965309dc5d6428d9
          name: 'Threads cached'
          type: DEPENDENT
          key: mysql.threads_cached
          description: 'Number of threads in the thread cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Threads_cached'')].Value.first()'
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: threads
        - uuid: af56c636c8b94e4f9976d0d6cf60fcbb
          name: 'Threads connected'
          type: DEPENDENT
          key: mysql.threads_connected
          description: 'Number of currently open connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Threads_connected'')].Value.first()'
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 8a50d5788f8a449b994dbe76536076a2
          name: 'Threads created per second'
          type: DEPENDENT
          key: mysql.threads_created.rate
          value_type: FLOAT
          description: 'Number of threads created to handle connections. If the value of `Threads_created` is large, you may want to increase the `thread_cache_size` value. The cache miss rate can be calculated as `Threads_created`/`Connections`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Threads_created'')].Value.first()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: threads
        - uuid: c41afa83f6a94efda34d7b41c95c89ac
          name: 'Threads running'
          type: DEPENDENT
          key: mysql.threads_running
          description: 'Number of threads that are not sleeping.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Threads_running'')].Value.first()'
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 8fbad224ebdf46e7b25a0be015f21972
          name: Uptime
          type: DEPENDENT
          key: mysql.uptime
          units: uptime
          description: 'Number of seconds that the server has been up.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.Variable_name==''Uptime'')].Value.first()'
          master_item:
            key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: ba9eb4fc244b41a6a30237e7a382fa54
              expression: 'nodata(/MySQL by ODBC/mysql.uptime,30m)=1'
              name: 'MySQL: Failed to fetch info data'
              event_name: 'MySQL: Failed to fetch info data (or no data for 30m)'
              priority: INFO
              description: 'Zabbix has not received any data for items for the last 30 minutes.'
              dependencies:
                - name: 'MySQL: Service is down'
                  expression: 'last(/MySQL by ODBC/db.odbc.select[ping,"{$MYSQL.DSN}"])=0'
              tags:
                - tag: scope
                  value: availability
            - uuid: cd8f5996bd85434998595e041d6b0908
              expression: 'last(/MySQL by ODBC/mysql.uptime)<10m'
              name: 'MySQL: Service has been restarted'
              event_name: 'MySQL: Service has been restarted (uptime < 10m)'
              priority: INFO
              description: 'MySQL uptime is less than 10 minutes.'
              tags:
                - tag: scope
                  value: notice
      discovery_rules:
        - uuid: 0987fb6afdae4587bc32864fa42728f2
          name: 'Database discovery'
          type: DEPENDENT
          key: mysql.database.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DATABASE}'
                value: '{$MYSQL.DBNAME.MATCHES}'
              - macro: '{#DATABASE}'
                value: '{$MYSQL.DBNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Used for the discovery of the databases.'
          item_prototypes:
            - uuid: f358179ef78b4a31affa9e049b4048b8
              name: 'Size of database {#DATABASE}'
              type: ODBC
              key: 'db.odbc.select[{#DATABASE}_size,"{$MYSQL.DSN}"]'
              delay: 5m
              units: B
              params: 'SELECT COALESCE(SUM(DATA_LENGTH + INDEX_LENGTH),0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA="{#DATABASE}"'
              username: '{$MYSQL.USER}'
              password: '{$MYSQL.PASSWORD}'
              description: 'Database size.'
              preprocessing:
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DATABASE}'
          master_item:
            key: 'db.odbc.get[get_database,"{$MYSQL.DSN}"]'
          lld_macro_paths:
            - lld_macro: '{#DATABASE}'
              path: $.Database
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: ad12522557df499e9a78b8b3c07733dd
          name: 'MariaDB discovery'
          type: DEPENDENT
          key: mysql.extra_metric.discovery
          description: 'Used for additional metrics if MariaDB is used.'
          item_prototypes:
            - uuid: eb8713584314461488b8769f1081d48d
              name: 'Binlog commits'
              type: DEPENDENT
              key: 'mysql.binlog_commits[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of transactions committed to the binary log.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.Variable_name==''Binlog_commits'')].Value.first()'
              master_item:
                key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: cbb7c1fadd934420b47950f52751795f
              name: 'Binlog group commits'
              type: DEPENDENT
              key: 'mysql.binlog_group_commits[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of group commits done to the binary log.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.Variable_name==''Binlog_group_commits'')].Value.first()'
              master_item:
                key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 278488a9c0f543f6815a24592766d9bb
              name: 'Master GTID wait count'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_count[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The number of times `MASTER_GTID_WAIT` called.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.Variable_name==''Master_gtid_wait_count'')].Value.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 93ad282dc3b24dba9f0351b0d0a59d39
              name: 'Master GTID wait timeouts'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_timeouts[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of timeouts occurring in `MASTER_GTID_WAIT`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.Variable_name==''Master_gtid_wait_timeouts'')].Value.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: fd8bf7e639af4d3291030cdb9dd37bc9
              name: 'Master GTID wait time'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_time[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of time spent in `MASTER_GTID_WAIT`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.Variable_name==''Master_gtid_wait_time'')].Value.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'db.odbc.get[get_status_variables,"{$MYSQL.DSN}"]'
              tags:
                - tag: component
                  value: transactions
          master_item:
            key: 'db.odbc.select[version,"{$MYSQL.DSN}"]'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return JSON.stringify(value.search(''MariaDB'')>-1 ? [{''{#SINGLETON}'': ''''}] : []);'
        - uuid: d0a235c0267c48e28bc6ecb99fb2380d
          name: 'Replication discovery'
          type: DEPENDENT
          key: mysql.replication.discovery
          description: 'Discovery of the replication.'
          item_prototypes:
            - uuid: 15f7b22867f54551afbed139d746e210
              name: 'Replication Seconds Behind Master {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.seconds_behind_master["{#MASTER_HOST}"]'
              units: s
              description: 'The number of seconds the slave SQL thread has been behind processing the master binary log. A high number (or an increasing one) can indicate that the slave is unable to handle events from the master in a timely fashion.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Seconds_Behind_Master
                - type: MATCHES_REGEX
                  parameters:
                    - \d+
                  error_handler: CUSTOM_ERROR
                  error_handler_params: 'Replication is not performed.'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.slave_status["{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: f2188a73bbf34ffcb95b3e11e2824feb
                  expression: 'min(/MySQL by ODBC/mysql.seconds_behind_master["{#MASTER_HOST}"],5m)>{$MYSQL.REPL_LAG.MAX.WARN}'
                  name: 'MySQL: Replication lag is too high'
                  event_name: 'MySQL: Replication lag is too high (over {$MYSQL.REPL_LAG.MAX.WARN} for 5m)'
                  priority: WARNING
                  description: 'Replication delay is too long.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: e063b116753d4124a88443fe4de20d41
              name: 'Replication Slave IO Running {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.slave_io_running["{#MASTER_HOST}"]'
              value_type: CHAR
              description: 'Whether the I/O thread for reading the master''s binary log is running. Normally, you want this to be `Yes` unless you have not yet started a replication or have explicitly stopped it with `STOP SLAVE`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Slave_IO_Running
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.slave_status["{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: 6f216036f4f14ae7adc8c70126bb315a
                  expression: 'count(/MySQL by ODBC/mysql.slave_io_running["{#MASTER_HOST}"],#1,"ne","Yes")=1'
                  name: 'MySQL: The slave I/O thread is not connected to a replication master'
                  priority: WARNING
                  description: 'Whether the slave I/O thread is connected to the master.'
                  dependencies:
                    - name: 'MySQL: The slave I/O thread is not running'
                      expression: 'count(/MySQL by ODBC/mysql.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  tags:
                    - tag: scope
                      value: availability
                - uuid: ba08061a61df4bbb8bac516ecec91b70
                  expression: 'count(/MySQL by ODBC/mysql.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  name: 'MySQL: The slave I/O thread is not running'
                  priority: AVERAGE
                  description: 'Whether the I/O thread for reading the master''s binary log is running.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 113be79554c14c2aad08036febb15d71
              name: 'Replication Slave SQL Running {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.slave_sql_running["{#MASTER_HOST}"]'
              value_type: CHAR
              description: |
                Whether the SQL thread for executing events in the relay log is running.
                As with the I/O thread, this should normally be `Yes`.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Slave_SQL_Running
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.slave_status["{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: 39d229e5e3f34e8b828b4a0e2eaa0026
                  expression: 'count(/MySQL by ODBC/mysql.slave_sql_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  name: 'MySQL: The SQL thread is not running'
                  priority: WARNING
                  description: 'Whether the SQL thread for executing events in the relay log is running.'
                  dependencies:
                    - name: 'MySQL: The slave I/O thread is not running'
                      expression: 'count(/MySQL by ODBC/mysql.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: a88eb463bb9740a4a4256306f11816bf
              name: 'Replication Slave SQL Running State {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.slave_sql_running_state["{#MASTER_HOST}"]'
              value_type: TEXT
              description: 'Shows the state of the SQL driver threads.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Slave_SQL_Running_State
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.slave_status["{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
            - uuid: d88f65c4bee84e74bb6e00061ab27f0c
              name: 'Replication Slave status {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.slave_status["{#MASTER_HOST}"]'
              history: '0'
              value_type: TEXT
              description: 'Gets status information on the essential parameters of the slave threads.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Master_Host==''{#MASTER_HOST}'')].first()'
              master_item:
                key: 'db.odbc.get[get_replication,"{$MYSQL.DSN}"]'
              tags:
                - tag: component
                  value: raw
          master_item:
            key: 'db.odbc.get[get_replication,"{$MYSQL.DSN}"]'
          lld_macro_paths:
            - lld_macro: '{#MASTER_HOST}'
              path: $.Master_Host
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: mysql
      macros:
        - macro: '{$MYSQL.ABORTED_CONN.MAX.WARN}'
          value: '3'
          description: 'Number of failed attempts to connect to the MySQL server for trigger expressions.'
          config:
            type: TEXT
            priority: '4'
            section_name: Thresholds
            label: 'Number of failed attempts to connect threshold'
            description: 'Threshold for the maximum number of failed attempts to connect to the MySQL server. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.BUFF_UTIL.MIN.WARN}'
          value: '50'
          description: 'The minimum buffer pool utilization in percentage for trigger expressions.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Buffer pool utilization threshold'
            description: 'Threshold of the minimum percentage of buffer pool utilization. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN}'
          value: '10'
          description: 'The maximum number of temporary tables created on a disk per second for trigger expressions.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Temporary tables created on a disk per second threshold'
            description: 'Threshold for the maximum number of temporary tables created on a disk per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_FILES.MAX.WARN}'
          value: '10'
          description: 'The maximum number of temporary files created on a disk per second for trigger expressions.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'Temporary files created on a disk per second threshold'
            description: 'Threshold for the maximum number of temporary files created on a disk per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_TABLES.MAX.WARN}'
          value: '30'
          description: 'The maximum number of temporary tables created in memory per second for trigger expressions.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Temporary tables created in memory per second threshold'
            description: 'Threshold for the maximum number of temporary tables created in memory per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.DBNAME.MATCHES}'
          value: .+
          description: 'Filter of discoverable databases.'
          config:
            type: TEXT
            priority: '12'
            section_name: Filters
            label: 'Include database filter'
            description: 'Regex string to include discovered database by its name.'
        - macro: '{$MYSQL.DBNAME.NOT_MATCHES}'
          value: information_schema
          description: 'Filter to exclude discovered databases.'
          config:
            type: TEXT
            priority: '13'
            section_name: Filters
            label: 'Exclude database filter'
            description: 'Regex string to exclude discovered database by its name.'
        - macro: '{$MYSQL.DSN}'
          description: 'System data source name.'
          config:
            type: TEXT
            priority: '1'
            label: 'MySQL DSN'
            description: 'Data source name of the MySQL instance.'
            required: 'YES'
        - macro: '{$MYSQL.INNODB_LOG_FILES}'
          value: '2'
          description: 'Number of physical files in the InnoDB redo log for calculating `innodb_log_file_size`.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'InnoDB redo log files number (for calculating)'
            description: 'Threshold for the maximum number of physical files in the InnoDB redo log for calculating `innodb_log_file_size`. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.PASSWORD}'
          type: SECRET_TEXT
          description: 'MySQL user password.'
          config:
            type: TEXT
            priority: '3'
            label: 'MySQL password'
            required: 'YES'
        - macro: '{$MYSQL.REPL_LAG.MAX.WARN}'
          value: 30m
          description: 'Amount of time the slave is behind the master for trigger expressions.'
          config:
            type: TEXT
            priority: '5'
            section_name: Thresholds
            label: 'Replication lag threshold'
            description: 'Threshold of the maximum time the slave is behind the master.'
        - macro: '{$MYSQL.SLOW_QUERIES.MAX.WARN}'
          value: '3'
          description: 'Number of slow queries for trigger expressions.'
          config:
            type: TEXT
            priority: '6'
            section_name: Thresholds
            label: 'Number of slow queries threshold'
            description: 'Threshold for the maximum number of slow queries. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.USER}'
          description: 'MySQL username.'
          config:
            type: TEXT
            priority: '2'
            label: 'MySQL user'
            required: 'YES'
      dashboards:
        - uuid: d56c53704c264552a09cf3e59a1835f3
          name: 'MySQL performance'
          pages:
            - widgets:
                - type: graph
                  name: 'MySQL: Operations'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by ODBC'
                        name: 'MySQL: Operations'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'MySQL: Connections'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by ODBC'
                        name: 'MySQL: Connections'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  name: 'MySQL: InnoDB buffer pool'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by ODBC'
                        name: 'MySQL: InnoDB buffer pool'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graph
                  name: 'MySQL: Queries'
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by ODBC'
                        name: 'MySQL: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: 'MySQL: Bandwidth'
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by ODBC'
                        name: 'MySQL: Bandwidth'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  name: 'MySQL: Threads'
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by ODBC'
                        name: 'MySQL: Threads'
                    - type: STRING
                      name: reference
                      value: AAAAF
      valuemaps:
        - uuid: 622c38d0af2a4b6ea7a640a5d1a22b93
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: f255e3fc32124b55b2a17ef3c961e5f5
      template: 'MySQL by Zabbix agent'
      name: 'MySQL by Zabbix agent'
      description: |
        Requirements for template operation:
        
        1. Install Zabbix agent and MySQL client. If necessary, add the path to the 'mysql' and 'mysqladmin' utilities to the global environment variable PATH.
        
        2. Copy the 'template_db_mysql.conf' file with user parameters into folder with Zabbix agent configuration (/etc/zabbix/zabbix_agentd.d/ by default). Don't forget to restart Zabbix agent.
        
        3. Create the MySQL user that will be used for monitoring ('<password>' at your discretion). For example:
        
        CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
        
        For more information, please see MySQL documentation (https://dev.mysql.com/doc/refman/8.0/en/grant.html).
        
        NOTE: In order to collect replication metrics, MariaDB Enterprise Server 10.5.8-5 and above and MariaDB Community Server 10.5.9 and above require the SLAVE MONITOR privilege to be set for the monitoring user:
        
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW,SLAVE MONITOR ON *.* TO 'zbx_monitor'@'%';
        
        For more information, please read the MariaDB documentation (https://mariadb.com/docs/server/ref/mdb/privileges/SLAVE_MONITOR/).
        
        4. Create '.my.cnf' configuration file in the home directory of Zabbix agent for Linux distributions (/var/lib/zabbix by default) or 'my.cnf' in c:\ for Windows. For example:
        
        [client]
        protocol=tcp
        user='zbx_monitor'
        password='<password>'
        
        For more information, please see MySQL documentation (https://dev.mysql.com/doc/refman/8.0/en/option-files.html).
        
        NOTE: Linux distributions that use SELinux may require additional steps for access configuration.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384189-discussion-thread-for-official-zabbix-template-db-mysql
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        1. Install MySQL client. If necessary, add the path to the `mysql` and `mysqladmin` utilities to the global environment variable PATH.
        2. Copy the `template_db_mysql.conf` file with user parameters into folder with Zabbix agent configuration (/etc/zabbix/zabbix_agentd.d/ by default). Don't forget to restart Zabbix agent.
        3. Create the MySQL user that will be used for monitoring (`<password>` at your discretion). For example:
        
        ```text
        CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
        ```
        
        For more information, please see [`MySQL documentation`](https://dev.mysql.com/doc/refman/8.0/en/grant.html).
        
        4. Create `.my.cnf` configuration file in the home directory of Zabbix agent for Linux distributions (/var/lib/zabbix by default) or `my.cnf` in c:\ for Windows. For example:
        
        ```text
        [client]
        protocol=tcp
        user='zbx_monitor'
        password='<password>'
        ```
        
        For more information, please see [`MySQL documentation`](https://dev.mysql.com/doc/refman/8.0/en/option-files.html).
        
        **NOTE:** In order to collect replication metrics, MariaDB Enterprise Server 10.5.8-5 and above and MariaDB Community Server 10.5.9 and above require the `SLAVE MONITOR` privilege to be set for the monitoring user:
        
        ```text
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW,SLAVE MONITOR ON *.* TO 'zbx_monitor'@'%';
        ```
        
        For more information, please read the [`MariaDB documentation`](https://mariadb.com/docs/server/ref/mdb/privileges/SLAVE_MONITOR/).
        
        NOTE: Linux distributions that use SELinux may require additional steps for access configuration.
        
        For example, the following rule could be added to the SELinux policy:
        
        ```text
        # cat <<EOF > zabbix_home.te
        module zabbix_home 1.0;
        
        require {
                type zabbix_agent_t;
                type zabbix_var_lib_t;
                type mysqld_etc_t;
                type mysqld_port_t;
                type mysqld_var_run_t;
                class file { open read };
                class tcp_socket name_connect;
                class sock_file write;
        }
        
        #============= zabbix_agent_t ==============
        
        allow zabbix_agent_t zabbix_var_lib_t:file read;
        allow zabbix_agent_t zabbix_var_lib_t:file open;
        allow zabbix_agent_t mysqld_etc_t:file read;
        allow zabbix_agent_t mysqld_port_t:tcp_socket name_connect;
        allow zabbix_agent_t mysqld_var_run_t:sock_file write;
        EOF
        # checkmodule -M -m -o zabbix_home.mod zabbix_home.te
        # semodule_package -o zabbix_home.pp -m zabbix_home.mod
        # semodule -i zabbix_home.pp
        # restorecon -R /var/lib/zabbix
        ```
      vendor:
        name: Zabbix
        version: 7.4-3
      groups:
        - name: Templates/Databases
      items:
        - uuid: b463e01655bf4dec81d5208f7a75766b
          name: 'Aborted clients per second'
          type: DEPENDENT
          key: mysql.aborted_clients.rate
          value_type: FLOAT
          description: 'Number of connections that were aborted because the client died without closing the connection properly.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Aborted_clients'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: d33a03e48f6d45dca04a505bab07a860
          name: 'Aborted connections per second'
          type: DEPENDENT
          key: mysql.aborted_connects.rate
          value_type: FLOAT
          description: 'Number of failed attempts to connect to the MySQL server.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Aborted_connects'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: e51c9ee3061c4e3889be1666afe6959d
              expression: 'min(/MySQL by Zabbix agent/mysql.aborted_connects.rate,5m)>{$MYSQL.ABORTED_CONN.MAX.WARN}'
              name: 'MySQL: Server has aborted connections'
              event_name: 'MySQL: Server has aborted connections (over {$MYSQL.ABORTED_CONN.MAX.WARN} for 5m)'
              priority: AVERAGE
              description: 'The number of failed attempts to connect to the MySQL server is more than `{$MYSQL.ABORTED_CONN.MAX.WARN}` in the last 5 minutes.'
              dependencies:
                - name: 'MySQL: Refused connections'
                  expression: 'last(/MySQL by Zabbix agent/mysql.connection_errors_max_connections.rate)>0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 75b9c78d76334927a3fc2a4d1322ecc2
          name: 'Binlog cache disk use'
          type: DEPENDENT
          key: mysql.binlog_cache_disk_use
          value_type: FLOAT
          description: 'Number of transactions that used a temporary disk cache because they could not fit in the regular binary log cache, being larger than `binlog_cache_size`.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Binlog_cache_disk_use'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 9a447424aca84124abdfa389865126d4
          name: 'Buffer pool efficiency'
          type: CALCULATED
          key: mysql.buffer_pool_efficiency
          value_type: FLOAT
          units: '%'
          params: |
            100 - (last(//mysql.innodb_buffer_pool_reads) / 
            ( last(//mysql.innodb_buffer_pool_read_requests) + 
            ( last(//mysql.innodb_buffer_pool_read_requests) = 0 ) ) * 100 * 
            ( last(//mysql.innodb_buffer_pool_read_requests) > 0 ))
          description: 'The item shows how effectively the buffer pool is serving reads.'
          tags:
            - tag: component
              value: memory
        - uuid: 9aca02e86e744f43ab48e8ca9453cf77
          name: 'Buffer pool utilization'
          type: CALCULATED
          key: mysql.buffer_pool_utilization
          value_type: FLOAT
          units: '%'
          params: |
            ( last(//mysql.innodb_buffer_pool_pages_total) - 
            last(//mysql.innodb_buffer_pool_pages_free) ) / 
            ( last(//mysql.innodb_buffer_pool_pages_total) + 
            ( last(//mysql.innodb_buffer_pool_pages_total) = 0 ) ) * 100 * 
            ( last(//mysql.innodb_buffer_pool_pages_total) > 0 )
          description: 'Ratio of used to total pages in the buffer pool.'
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 0e8ea91d72a64507aaadf9ea5efa6412
              expression: 'max(/MySQL by Zabbix agent/mysql.buffer_pool_utilization,5m)<{$MYSQL.BUFF_UTIL.MIN.WARN}'
              name: 'MySQL: Buffer pool utilization is too low'
              event_name: 'MySQL: Buffer pool utilization is too low (less than {$MYSQL.BUFF_UTIL.MIN.WARN}% for 5m)'
              priority: WARNING
              description: 'The buffer pool utilization is less than `{$MYSQL.BUFF_UTIL.MIN.WARN}`% in the last 5 minutes. This means that there is a lot of unused RAM allocated for the buffer pool, which you can easily reallocate at the moment.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 56512a1e89d34826ad261ab27119e80d
          name: 'Bytes received'
          type: DEPENDENT
          key: mysql.bytes_received.rate
          value_type: FLOAT
          units: Bps
          description: 'Number of bytes received from all clients.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Bytes_received'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: network
        - uuid: c4cea16e3dbe4d328d9a50e113f3b904
          name: 'Bytes sent'
          type: DEPENDENT
          key: mysql.bytes_sent.rate
          value_type: FLOAT
          units: Bps
          description: 'Number of bytes sent to all clients.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Bytes_sent'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: network
        - uuid: 24ab8f0bd32a45f591c676ef839876df
          name: 'Command Delete per second'
          type: DEPENDENT
          key: mysql.com_delete.rate
          value_type: FLOAT
          description: 'The `Com_delete` counter variable indicates the number of times the `DELETE` statement has been executed.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Com_delete'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: operations
        - uuid: e48c67c893e5494fb00ea31222bd2caf
          name: 'Command Insert per second'
          type: DEPENDENT
          key: mysql.com_insert.rate
          value_type: FLOAT
          description: 'The `Com_insert` counter variable indicates the number of times the `INSERT` statement has been executed.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Com_insert'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: operations
        - uuid: 718c3af61f2645e8ab7d3496d6639c79
          name: 'Command Select per second'
          type: DEPENDENT
          key: mysql.com_select.rate
          value_type: FLOAT
          description: 'The `Com_select` counter variable indicates the number of times the `SELECT` statement has been executed.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Com_select'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: operations
        - uuid: e2c3ea26dd34472c9e5f0e48a67da6dd
          name: 'Command Update per second'
          type: DEPENDENT
          key: mysql.com_update.rate
          value_type: FLOAT
          description: 'The `Com_update` counter variable indicates the number of times the `UPDATE` statement has been executed.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Com_update'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: operations
        - uuid: bcf8a21aacc54a79a958604b278f9617
          name: 'Connections per second'
          type: DEPENDENT
          key: mysql.connections.rate
          value_type: FLOAT
          description: 'Number of connection attempts (successful or not) to the MySQL server.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connections'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: dc963a1250ab453cb090af0154d745c3
          name: 'Connection errors accept per second'
          type: DEPENDENT
          key: mysql.connection_errors_accept.rate
          value_type: FLOAT
          description: 'Number of errors that occurred during calls to `accept()` on the listening port.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_accept'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 4cff4caf382f4f00b534651212132bd2
          name: 'Connection errors internal per second'
          type: DEPENDENT
          key: mysql.connection_errors_internal.rate
          value_type: FLOAT
          description: 'Number of refused connections due to internal server errors, for example, out of memory errors, or failed thread starts.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_internal'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 3cbc55fc7b764a61baceb11e98fd454c
          name: 'Connection errors max connections per second'
          type: DEPENDENT
          key: mysql.connection_errors_max_connections.rate
          value_type: FLOAT
          description: 'Number of refused connections due to the `max_connections` limit being reached.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_max_connections'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: 2ff2d0f399df4cb08b7196d3a4690567
              expression: 'last(/MySQL by Zabbix agent/mysql.connection_errors_max_connections.rate)>0'
              name: 'MySQL: Refused connections'
              event_name: 'MySQL: Refused connections (max_connections limit reached)'
              priority: AVERAGE
              description: 'Number of refused connections due to the `max_connections` limit being reached.'
              tags:
                - tag: scope
                  value: availability
        - uuid: e577b4b6c553401bbb831b7278dbbcb7
          name: 'Connection errors peer address per second'
          type: DEPENDENT
          key: mysql.connection_errors_peer_address.rate
          value_type: FLOAT
          description: 'Number of errors while searching for the connecting client''s IP address.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_peer_address'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 228aaf5333ce4958aa3a07e0898add63
          name: 'Connection errors select per second'
          type: DEPENDENT
          key: mysql.connection_errors_select.rate
          value_type: FLOAT
          description: 'Number of errors during calls to `select()` or `poll()` on the listening port. The client would not necessarily have been rejected in these cases.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_select'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: a7632124b2b648bfa80a2e8a0381f4d2
          name: 'Connection errors tcpwrap per second'
          type: DEPENDENT
          key: mysql.connection_errors_tcpwrap.rate
          value_type: FLOAT
          description: 'Number of connections the libwrap library has refused.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_tcpwrap'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 52335a039571454ebaccc9ab103200a3
          name: 'Created tmp tables on disk per second'
          type: DEPENDENT
          key: mysql.created_tmp_disk_tables.rate
          value_type: FLOAT
          description: 'Number of internal on-disk temporary tables created by the server while executing statements.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Created_tmp_disk_tables'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: storage
            - tag: component
              value: tables
          triggers:
            - uuid: 1b8761292e89476e91834f8e567a1dbe
              expression: 'min(/MySQL by Zabbix agent/mysql.created_tmp_disk_tables.rate,5m)>{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN}'
              name: 'MySQL: Number of on-disk temporary tables created per second is high'
              event_name: 'MySQL: Number of on-disk temporary tables created per second is high (over {$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: d1dd183666d44010a5054f2e1cc328de
          name: 'Created tmp files on disk per second'
          type: DEPENDENT
          key: mysql.created_tmp_files.rate
          value_type: FLOAT
          description: 'How many temporary files `mysqld` has created.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Created_tmp_files'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 9845d8dc676f4702ae34b626f39d21ac
              expression: 'min(/MySQL by Zabbix agent/mysql.created_tmp_files.rate,5m)>{$MYSQL.CREATED_TMP_FILES.MAX.WARN}'
              name: 'MySQL: Number of temporary files created per second is high'
              event_name: 'MySQL: Number of temporary files created per second is high (over {$MYSQL.CREATED_TMP_FILES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: c9a94c3145a643ef8ceec33f63b85ae9
          name: 'Created tmp tables on memory per second'
          type: DEPENDENT
          key: mysql.created_tmp_tables.rate
          value_type: FLOAT
          description: 'Number of internal temporary tables created by the server while executing statements.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Created_tmp_tables'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: tables
          triggers:
            - uuid: c647a51864e04bc69a1f610b1dec56fe
              expression: 'min(/MySQL by Zabbix agent/mysql.created_tmp_tables.rate,5m)>{$MYSQL.CREATED_TMP_TABLES.MAX.WARN}'
              name: 'MySQL: Number of internal temporary tables created per second is high'
              event_name: 'MySQL: Number of internal temporary tables created per second is high (over {$MYSQL.CREATED_TMP_TABLES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 2ba81b425bde4ba5b3f7d00a6c922ed9
          name: 'Get status variables'
          key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          history: '0'
          value_type: TEXT
          description: 'Gets server global status information.'
          tags:
            - tag: component
              value: raw
        - uuid: a9b965a07b504fa1b4e90acae0156221
          name: 'InnoDB buffer pool pages free'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_pages_free
          description: 'The total size of the InnoDB buffer pool, in pages.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_pages_free'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: efb2450fe30c4ec78b954a35595b7ac7
          name: 'InnoDB buffer pool pages total'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_pages_total
          description: 'The total size of the InnoDB buffer pool, in pages.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_pages_total'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 7738a4480f69427a96d46a9ca5b38d77
          name: 'InnoDB buffer pool reads'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_reads
          description: 'Number of logical reads that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_reads'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 1704fe0bf8de4882a6a16ebd75c4c3bf
          name: 'InnoDB buffer pool reads per second'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_reads.rate
          value_type: FLOAT
          description: 'Number of logical reads per second that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_reads'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 598dcdb7eeec42c78484be70c814cd8a
          name: 'InnoDB buffer pool read requests'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_read_requests
          description: 'Number of logical read requests.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_read_requests'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 3ed432f4e0c949debaed9d60c5d13810
          name: 'InnoDB buffer pool read requests per second'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_read_requests.rate
          value_type: FLOAT
          description: 'Number of logical read requests per second.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_read_requests'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 61db0feae0b440c087177f4312eb6b7a
          name: 'Innodb buffer pool wait free'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_wait_free
          value_type: FLOAT
          description: 'Number of times InnoDB waited for a free page before reading or creating a page. Normally, writes to the InnoDB buffer pool happen in the background. When no clean pages are available, dirty pages are flushed first in order to free some up. This counts the numbers of wait for this operation to finish. If this value is not small, look at the increasing `innodb_buffer_pool_size`.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_wait_free'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: e5413d85449e4baea683c6365808cc17
          name: 'Calculated value of innodb_log_file_size'
          type: CALCULATED
          key: mysql.innodb_log_file_size
          value_type: FLOAT
          params: '(last(//mysql.innodb_os_log_written) - last(//mysql.innodb_os_log_written,#1:now-1h)) / {$MYSQL.INNODB_LOG_FILES}'
          description: '`Innodb_log_file_size` is calculated as: (`innodb_os_log_written`-`innodb_os_log_written`(time shift -1h))/`{$MYSQL.INNODB_LOG_FILES}`. `Innodb_log_file_size` is the size in bytes of the each InnoDB redo log file in the log group. The combined size can be no more than 512 GB. Larger values mean less disk I/O due to less flushing checkpoint activity, but also slower recovery from a crash.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          tags:
            - tag: component
              value: system
        - uuid: 2eacd8c07f7148acaaa9b8f8602720ae
          name: 'Innodb number open files'
          type: DEPENDENT
          key: mysql.innodb_num_open_files
          value_type: FLOAT
          description: 'Number of open files held by InnoDB. InnoDB only.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_num_open_files'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: system
        - uuid: 29d3513668ad4bdea28d947d2f983dd2
          name: 'Innodb log written'
          type: DEPENDENT
          key: mysql.innodb_os_log_written
          value_type: FLOAT
          units: B
          description: 'Number of bytes written to the InnoDB log.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_os_log_written'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: system
        - uuid: 3811018fdfaf4d92a5b8ff5d631d0047
          name: 'InnoDB row lock time'
          type: DEPENDENT
          key: mysql.innodb_row_lock_time
          value_type: FLOAT
          units: s
          description: 'The total time spent in acquiring row locks for InnoDB tables, in milliseconds.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_row_lock_time'']/field[@name=''Value'']/text()'
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: 579c1ad7680349a3b6a25dd12322fc14
          name: 'InnoDB row lock time max'
          type: DEPENDENT
          key: mysql.innodb_row_lock_time_max
          value_type: FLOAT
          units: s
          description: 'The maximum time to acquire a row lock for InnoDB tables, in milliseconds.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_row_lock_time_max'']/field[@name=''Value'']/text()'
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: a4618dd9ed1d4ff19f34bc82f41dbbbb
          name: 'InnoDB row lock waits'
          type: DEPENDENT
          key: mysql.innodb_row_lock_waits
          description: 'Number of times operations on InnoDB tables had to wait for a row lock.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_row_lock_waits'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: e207dc3c0fe84928a36e643594d8cee5
          name: 'Max used connections'
          type: DEPENDENT
          key: mysql.max_used_connections
          description: 'The maximum number of connections that have been in use simultaneously since the server start.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Max_used_connections'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 3dd5ffb7c1cc45a487c5c7cabfa90ca6
          name: 'Open tables'
          type: DEPENDENT
          key: mysql.open_tables
          value_type: FLOAT
          description: 'Number of tables that are open.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Open_tables'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: tables
        - uuid: fe572969a6754248b10a35a5c0afedf3
          name: 'Open table definitions'
          type: DEPENDENT
          key: mysql.open_table_definitions
          value_type: FLOAT
          description: 'Number of cached table definitions.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Open_table_definitions'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: tables
        - uuid: 41cd6c8c535948f3bde6324e0912f1a8
          name: Status
          key: 'mysql.ping["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          description: 'MySQL server status.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return value.indexOf(''is alive'') !== -1 ? 1 : 0;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: e78f07e3e507461f8fe33a31b1bc4eb9
              expression: 'last(/MySQL by Zabbix agent/mysql.ping["{$MYSQL.HOST}","{$MYSQL.PORT}"])=0'
              name: 'MySQL: Service is down'
              priority: HIGH
              description: 'MySQL is down.'
              tags:
                - tag: scope
                  value: availability
        - uuid: c11b8c8ec3e843cea63f6cc1d8309ccd
          name: 'Queries per second'
          type: DEPENDENT
          key: mysql.queries.rate
          value_type: FLOAT
          description: 'Number of statements executed by the server. This variable includes statements executed within stored programs, unlike the `Questions` variable.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Queries'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: queries
        - uuid: cd7c5c4e262f4a73975d46d06ed903f9
          name: 'Questions per second'
          type: DEPENDENT
          key: mysql.questions.rate
          value_type: FLOAT
          description: 'Number of statements executed by the server. This includes only statements sent to the server by clients and not statements executed within stored programs, unlike the `Queries` variable.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Questions'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: queries
        - uuid: a1cfc616f23648e9946f408c7146df0a
          name: 'Slow queries per second'
          type: DEPENDENT
          key: mysql.slow_queries.rate
          value_type: FLOAT
          description: 'Number of queries that have taken more than `long_query_time` seconds.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Slow_queries'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: queries
          triggers:
            - uuid: 113509b7a7b54a108c1c63346a52bbf2
              expression: 'min(/MySQL by Zabbix agent/mysql.slow_queries.rate,5m)>{$MYSQL.SLOW_QUERIES.MAX.WARN}'
              name: 'MySQL: Server has slow queries'
              event_name: 'MySQL: Server has slow queries (over {$MYSQL.SLOW_QUERIES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The number of slow queries is more than `{$MYSQL.SLOW_QUERIES.MAX.WARN}` in the last 5 minutes.'
              tags:
                - tag: scope
                  value: performance
        - uuid: a9ce1d75a97d4740876fad7b5d569211
          name: 'Threads cached'
          type: DEPENDENT
          key: mysql.threads_cached
          description: 'Number of threads in the thread cache.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Threads_cached'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: threads
        - uuid: a0079f5ffbdc40cc89b35a8b6170c32b
          name: 'Threads connected'
          type: DEPENDENT
          key: mysql.threads_connected
          description: 'Number of currently open connections.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Threads_connected'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 06976fcb42ab4a33b0056a864ecd31e7
          name: 'Threads created per second'
          type: DEPENDENT
          key: mysql.threads_created.rate
          value_type: FLOAT
          description: 'Number of threads created to handle connections. If the value of `Threads_created` is large, you may want to increase the `thread_cache_size` value. The cache miss rate can be calculated as `Threads_created`/`Connections`.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Threads_created'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 255c00a984ba462e84ba46a7430f21c9
          name: 'Threads running'
          type: DEPENDENT
          key: mysql.threads_running
          description: 'Number of threads that are not sleeping.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Threads_running'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 6ffa704603014f0f9f765590955fb01c
          name: Uptime
          type: DEPENDENT
          key: mysql.uptime
          units: uptime
          description: 'Number of seconds that the server has been up.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Uptime'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: d3c80c770355464fb5a6be0357d0edca
              expression: 'nodata(/MySQL by Zabbix agent/mysql.uptime,30m)=1'
              name: 'MySQL: Failed to fetch info data'
              event_name: 'MySQL: Failed to fetch info data (or no data for 30m)'
              priority: INFO
              description: 'Zabbix has not received any data for items for the last 30 minutes.'
              dependencies:
                - name: 'MySQL: Service is down'
                  expression: 'last(/MySQL by Zabbix agent/mysql.ping["{$MYSQL.HOST}","{$MYSQL.PORT}"])=0'
              tags:
                - tag: scope
                  value: availability
            - uuid: f02f51c764934cf394c5ad3f9c4e70d2
              expression: 'last(/MySQL by Zabbix agent/mysql.uptime)<10m'
              name: 'MySQL: Service has been restarted'
              event_name: 'MySQL: Service has been restarted (uptime < 10m)'
              priority: INFO
              description: 'MySQL uptime is less than 10 minutes.'
              tags:
                - tag: scope
                  value: notice
        - uuid: a5d0f152c3ef4e069c3d5a6a5a9470fe
          name: Version
          key: 'mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          delay: 15m
          value_type: CHAR
          description: 'MySQL server version.'
          preprocessing:
            - type: REGEX
              parameters:
                - '(Server version)\s+(.+)'
                - \2
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 7eab3a7337904ad1b2061d209371543b
              expression: 'last(/MySQL by Zabbix agent/mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"],#1)<>last(/MySQL by Zabbix agent/mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"],#2) and length(last(/MySQL by Zabbix agent/mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"]))>0'
              name: 'MySQL: Version has changed'
              event_name: 'MySQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              description: 'The MySQL version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
      discovery_rules:
        - uuid: 8ceb226f000d48f099ee6e128ad551b5
          name: 'Database discovery'
          key: 'mysql.db.discovery["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          delay: 1h
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DBNAME}'
                value: '{$MYSQL.DBNAME.MATCHES}'
              - macro: '{#DBNAME}'
                value: '{$MYSQL.DBNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Scanning databases in DBMS.'
          item_prototypes:
            - uuid: dda45077011d4f8fa5c25b1f351179ca
              name: 'Size of database {#DBNAME}'
              key: 'mysql.dbsize["{$MYSQL.HOST}","{$MYSQL.PORT}","{#DBNAME}"]'
              delay: 5m
              units: B
              description: 'Database size.'
              preprocessing:
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  return JSON.stringify(value.split("\n").map(function (name) {
                  	return ({"{#DBNAME}": name});
                  }));
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: bc28468760e14d069ef7b47858846a50
          name: 'MariaDB discovery'
          type: DEPENDENT
          key: mysql.extra_metric.discovery
          description: 'Used for additional metrics if MariaDB is used.'
          item_prototypes:
            - uuid: 7743cdbaf71c491189ac1a927409e998
              name: 'Binlog commits'
              type: DEPENDENT
              key: 'mysql.binlog_commits[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of transactions committed to the binary log.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Binlog_commits'']/field[@name=''Value'']/text()'
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: c897f8f0fb1c4e409dd95305fd221e01
              name: 'Binlog group commits'
              type: DEPENDENT
              key: 'mysql.binlog_group_commits[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of group commits done to the binary log.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Binlog_group_commits'']/field[@name=''Value'']/text()'
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 749e72ebd1014f7faee352e23ac3dfdd
              name: 'Master GTID wait count'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_count[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The number of times `MASTER_GTID_WAIT` called.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Master_gtid_wait_count'']/field[@name=''Value'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 4a4537b0db5b43119af910d0ba421035
              name: 'Master GTID wait timeouts'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_timeouts[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of timeouts occurring in `MASTER_GTID_WAIT`.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Master_gtid_wait_timeouts'']/field[@name=''Value'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: c1e95abc88cf486a9226bf760254f797
              name: 'Master GTID wait time'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_time[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of time spent in `MASTER_GTID_WAIT`.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Master_gtid_wait_time'']/field[@name=''Value'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
              tags:
                - tag: component
                  value: transactions
          master_item:
            key: 'mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return JSON.stringify(value.search(''MariaDB'')>-1 ? [{''{#SINGLETON}'': ''''}] : []);'
        - uuid: aed60b7ae3794d0ba25ad82da12b8966
          name: 'Replication discovery'
          key: 'mysql.replication.discovery["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          delay: 1h
          description: 'If "show slave status" returns Master_Host, "Replication: *" items are created.'
          item_prototypes:
            - uuid: 48555d71074f4cd4a61dca6187c8b29a
              name: 'Replication Seconds Behind Master {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.seconds_behind_master["{#MASTER_HOST}"]'
              units: s
              description: |
                The number of seconds that the slave SQL thread is behind processing the master binary log.
                A high number (or an increasing one) can indicate that the slave is unable to handle events
                from the master in a timely fashion.
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row/field[@name=''Seconds_Behind_Master'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
                - type: NOT_MATCHES_REGEX
                  parameters:
                    - 'null'
                  error_handler: CUSTOM_ERROR
                  error_handler_params: 'Replication is not performed.'
              master_item:
                key: 'mysql.slave_status["{$MYSQL.HOST}","{$MYSQL.PORT}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: a5c91da088414d279f5ea3cd59093ce9
                  expression: 'min(/MySQL by Zabbix agent/mysql.seconds_behind_master["{#MASTER_HOST}"],5m)>{$MYSQL.REPL_LAG.MAX.WARN}'
                  name: 'MySQL: Replication lag is too high'
                  event_name: 'MySQL: Replication lag is too high (over {$MYSQL.REPL_LAG.MAX.WARN} for 5m)'
                  priority: WARNING
                  description: 'Replication delay is too long.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 1c075f4785604d92a33a868e213070d8
              name: 'Replication Slave IO Running {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.slave_io_running["{#MASTER_HOST}"]'
              value_type: CHAR
              description: |
                Whether the I/O thread for reading the master's binary log is running.
                Normally, you want this to be Yes unless you have not yet started replication or have
                explicitly stopped it with STOP SLAVE.
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row/field[@name=''Slave_IO_Running'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.slave_status["{$MYSQL.HOST}","{$MYSQL.PORT}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: 8ee45932311443cb906306b1d2c99b19
                  expression: 'count(/MySQL by Zabbix agent/mysql.slave_io_running["{#MASTER_HOST}"],#1,"ne","Yes")=1'
                  name: 'MySQL: The slave I/O thread is not connected to a replication master'
                  priority: WARNING
                  description: 'Whether the slave I/O thread is connected to the master.'
                  dependencies:
                    - name: 'MySQL: The slave I/O thread is not running'
                      expression: 'count(/MySQL by Zabbix agent/mysql.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  tags:
                    - tag: scope
                      value: availability
                - uuid: 4c8ca45f26254d9a9a1c9248f1fa1537
                  expression: 'count(/MySQL by Zabbix agent/mysql.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  name: 'MySQL: The slave I/O thread is not running'
                  priority: AVERAGE
                  description: 'Whether the I/O thread for reading the master''s binary log is running.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 967c6fd13cc04562a9fea174bd90b8c4
              name: 'Replication Slave SQL Running {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.slave_sql_running["{#MASTER_HOST}"]'
              value_type: CHAR
              description: |
                Whether the SQL thread for executing events in the relay log is running.
                As with the I/O thread, this should normally be Yes.
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row/field[@name=''Slave_SQL_Running'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.slave_status["{$MYSQL.HOST}","{$MYSQL.PORT}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: bd0d20c05e3b46b6a7c341e5d122208b
                  expression: 'count(/MySQL by Zabbix agent/mysql.slave_sql_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  name: 'MySQL: The SQL thread is not running'
                  priority: WARNING
                  description: 'Whether the SQL thread for executing events in the relay log is running.'
                  dependencies:
                    - name: 'MySQL: The slave I/O thread is not running'
                      expression: 'count(/MySQL by Zabbix agent/mysql.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 27e807d840d4474484c2e1f896726b6b
              name: 'Replication Slave SQL Running State {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.slave_sql_running_state["{#MASTER_HOST}"]'
              value_type: TEXT
              description: 'This shows the state of the SQL driver threads.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Slave_SQL_Running_State'']/field[@name=''Value'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.slave_status["{$MYSQL.HOST}","{$MYSQL.PORT}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
            - uuid: d87c7c03e5884a43912f60ad91c3b46f
              name: 'Replication Slave status {#MASTER_HOST}'
              key: 'mysql.slave_status["{$MYSQL.HOST}","{$MYSQL.PORT}","{#MASTER_HOST}"]'
              history: '0'
              value_type: TEXT
              description: 'The item gets status information on the essential parameters of the slave threads.'
              tags:
                - tag: component
                  value: raw
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var matches = value.match(/Master_Host.*>(.*)<.*/);
                  if (matches) {
                  	return JSON.stringify([{"{#MASTER_HOST}": matches[1]}]);
                  }
                  
                  return '[]';
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: mysql
      macros:
        - macro: '{$MYSQL.ABORTED_CONN.MAX.WARN}'
          value: '3'
          description: 'Number of failed attempts to connect to the MySQL server for trigger expressions.'
          config:
            type: TEXT
            priority: '3'
            section_name: Thresholds
            label: 'Number of failed attempts to connect threshold'
            description: 'Threshold for the maximum number of failed attempts to connect to the MySQL server. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.BUFF_UTIL.MIN.WARN}'
          value: '50'
          description: 'The minimum buffer pool utilization in percentage for trigger expressions.'
          config:
            type: TEXT
            priority: '6'
            section_name: Thresholds
            label: 'Buffer pool utilization threshold'
            description: 'Threshold of the minimum percentage of buffer pool utilization. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN}'
          value: '10'
          description: 'The maximum number of temporary tables created on a disk per second for trigger expressions.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Temporary tables created on a disk per second threshold'
            description: 'Threshold for the maximum number of temporary tables created on a disk per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_FILES.MAX.WARN}'
          value: '10'
          description: 'The maximum number of temporary files created on a disk per second for trigger expressions.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Temporary files created on a disk per second threshold'
            description: 'Threshold for the maximum number of temporary files created on a disk per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_TABLES.MAX.WARN}'
          value: '30'
          description: 'The maximum number of temporary tables created in memory per second for trigger expressions.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Temporary tables created in memory per second threshold'
            description: 'Threshold for the maximum number of temporary tables created in memory per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.DBNAME.MATCHES}'
          value: .+
          description: 'Filter of discoverable databases.'
          config:
            type: TEXT
            priority: '11'
            section_name: Filters
            label: 'Include database filter'
            description: 'Regex string to include discovered database by its name.'
        - macro: '{$MYSQL.DBNAME.NOT_MATCHES}'
          value: information_schema
          description: 'Filter to exclude discovered databases.'
          config:
            type: TEXT
            priority: '12'
            section_name: Filters
            label: 'Exclude database filter'
            description: 'Regex string to exclude discovered database by its name.'
        - macro: '{$MYSQL.HOST}'
          value: 127.0.0.1
          description: 'Hostname or IP of MySQL host or container.'
          config:
            type: TEXT
            priority: '1'
            label: 'MySQL address'
            description: 'Hostname or IP address of MySQL host or container.'
        - macro: '{$MYSQL.INNODB_LOG_FILES}'
          value: '2'
          description: 'Number of physical files in the InnoDB redo log for calculating `innodb_log_file_size`.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'InnoDB redo log files number (for calculating)'
            description: 'Threshold for the maximum number of physical files in the InnoDB redo log for calculating `innodb_log_file_size`. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.PORT}'
          value: '3306'
          description: 'MySQL service port.'
          config:
            type: TEXT
            priority: '2'
            label: 'MySQL service port'
            description: 'In the range from 1 to 65535 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.REPL_LAG.MAX.WARN}'
          value: 30m
          description: 'Amount of time the slave is behind the master for trigger expressions.'
          config:
            type: TEXT
            priority: '4'
            section_name: Thresholds
            label: 'Replication lag threshold'
            description: 'Threshold of the maximum time the slave is behind the master.'
        - macro: '{$MYSQL.SLOW_QUERIES.MAX.WARN}'
          value: '3'
          description: 'Number of slow queries for trigger expressions.'
          config:
            type: TEXT
            priority: '5'
            section_name: Thresholds
            label: 'Number of slow queries threshold'
            description: 'Threshold for the maximum number of slow queries. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
      dashboards:
        - uuid: ce2f9d7bb18e469f97e692baee02841d
          name: 'MySQL performance'
          pages:
            - widgets:
                - type: graph
                  name: 'MySQL: Operations'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent'
                        name: 'MySQL: Operations'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'MySQL: Connections'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent'
                        name: 'MySQL: Connections'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  name: 'MySQL: InnoDB buffer pool'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent'
                        name: 'MySQL: InnoDB buffer pool'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graph
                  name: 'MySQL: Queries'
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent'
                        name: 'MySQL: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: 'MySQL: Bandwidth'
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent'
                        name: 'MySQL: Bandwidth'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  name: 'MySQL: Threads'
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent'
                        name: 'MySQL: Threads'
                    - type: STRING
                      name: reference
                      value: AAAAF
      valuemaps:
        - uuid: 4f2d7ca3c89246c6b691557447230031
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: 4904f84303c74c5e955b7849730c3155
      template: 'MySQL by Zabbix agent 2'
      name: 'MySQL by Zabbix agent 2'
      description: |
        Requirements for template operation:
        
        1. Create a MySQL user for monitoring. For example:
        
        CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
        
        For more information please read the MySQL documentation https://dev.mysql.com/doc/refman/8.0/en/grant.html.
        
        NOTE: In order to collect replication metrics, MariaDB Enterprise Server 10.5.8-5 and above and MariaDB Community Server 10.5.9 and above require the SLAVE MONITOR privilege to be set for the monitoring user:
        
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW,SLAVE MONITOR ON *.* TO 'zbx_monitor'@'%';
        
        For more information please read the MariaDB documentation https://mariadb.com/docs/server/ref/mdb/privileges/SLAVE_MONITOR/
        
        2. Set in the {$MYSQL.DSN} macro the data source name of the MySQL instance either session name from Zabbix agent 2 configuration file or URI.
        Examples: MySQL1, tcp://localhost:3306, tcp://172.16.0.10, unix:/var/run/mysql.sock
        For more information about MySQL Unix socket file please read the MySQL documentation https://dev.mysql.com/doc/refman/8.0/en/problems-with-mysql-sock.html.
        
        3. If you had set URI in the {$MYSQL.DSN}, please define the user name and password in host macros ({$MYSQL.USER} and {$MYSQL.PASSWORD}).
        Leave macros {$MYSQL.USER} and {$MYSQL.PASSWORD} empty if you use a session name. Set the user name and password in the Plugins.Mysql.<...> section of your Zabbix agent 2 configuration file.
        For more information about configuring the Zabbix MySQL plugin please read the documentation https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/src/go/plugins/mysql/README.md.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384189-discussion-thread-for-official-zabbix-template-db-mysql
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        1. Create a MySQL user for monitoring (`<password>` at your discretion):
        
        ```text
        CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
        ```
        
        For more information, please see MySQL documentation https://dev.mysql.com/doc/refman/8.0/en/grant.html
        
        **NOTE:** In order to collect replication metrics, MariaDB Enterprise Server 10.5.8-5 and above and MariaDB Community Server 10.5.9 and above require the `SLAVE MONITOR` privilege to be set for the monitoring user:
        
        ```text
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW,SLAVE MONITOR ON *.* TO 'zbx_monitor'@'%';
        ```
        
        For more information please read the MariaDB documentation https://mariadb.com/docs/server/ref/mdb/privileges/SLAVE_MONITOR/
        
        2. Set in the `MySQL DSN` host wizard configuration field macro the data source name of the MySQL instance either session name from Zabbix agent 2 configuration file or URI.
        **Examples:** MySQL1, tcp://localhost:3306, tcp://172.16.0.10, unix:/var/run/mysql.sock
        For more information about MySQL Unix socket file, see the MySQL documentation https://dev.mysql.com/doc/refman/8.0/en/problems-with-mysql-sock.html.
        
        3. If you had set URI in the `MySQL DSN` field, define the user name and password in `MySQL user` and `MySQL password` host wizard configuration fields.
        Leave fields `MySQL user` and `MySQL password` empty if you use a session name. Set the user name and password in the Plugins.Mysql.<...> section of your Zabbix agent 2 configuration file.
        For more information about configuring the Zabbix MySQL plugin, see the documentation https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/src/go/plugins/mysql/README.md.
      vendor:
        name: Zabbix
        version: 7.4-3
      groups:
        - name: Templates/Databases
      items:
        - uuid: 8a7b77d4e96a4a2d93f63eb8ca3c979b
          name: 'Aborted clients per second'
          type: DEPENDENT
          key: mysql.aborted_clients.rate
          value_type: FLOAT
          description: 'Number of connections that were aborted because the client died without closing the connection properly.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Aborted_clients
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 77a407bb911f4b938c32de289da83383
          name: 'Aborted connections per second'
          type: DEPENDENT
          key: mysql.aborted_connects.rate
          value_type: FLOAT
          description: 'Number of failed attempts to connect to the MySQL server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Aborted_connects
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: 0f984c4458ae4a7f9388b1edb42090bf
              expression: 'min(/MySQL by Zabbix agent 2/mysql.aborted_connects.rate,5m)>{$MYSQL.ABORTED_CONN.MAX.WARN}'
              name: 'MySQL: Server has aborted connections'
              event_name: 'MySQL: Server has aborted connections (over {$MYSQL.ABORTED_CONN.MAX.WARN} for 5m)'
              priority: AVERAGE
              description: 'The number of failed attempts to connect to the MySQL server is more than `{$MYSQL.ABORTED_CONN.MAX.WARN}` in the last 5 minutes.'
              dependencies:
                - name: 'MySQL: Refused connections'
                  expression: 'last(/MySQL by Zabbix agent 2/mysql.connection_errors_max_connections.rate)>0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 06338fe53a014be095f3807d58b9ed5b
          name: 'Binlog cache disk use'
          type: DEPENDENT
          key: mysql.binlog_cache_disk_use
          value_type: FLOAT
          description: 'Number of transactions that used a temporary disk cache because they could not fit in the regular binary log cache, being larger than `binlog_cache_size`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Binlog_cache_disk_use
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: cache
        - uuid: e222b97642d04128af8c1ec20e463152
          name: 'Buffer pool efficiency'
          type: CALCULATED
          key: mysql.buffer_pool_efficiency
          value_type: FLOAT
          units: '%'
          params: |
            100 - (last(//mysql.innodb_buffer_pool_reads) / 
            ( last(//mysql.innodb_buffer_pool_read_requests) + 
            ( last(//mysql.innodb_buffer_pool_read_requests) = 0 ) ) * 100 * 
            ( last(//mysql.innodb_buffer_pool_read_requests) > 0 ))
          description: 'The item shows how effectively the buffer pool is serving reads.'
          tags:
            - tag: component
              value: memory
        - uuid: 70a1642e80114fd3a129c5774acc4f50
          name: 'Buffer pool utilization'
          type: CALCULATED
          key: mysql.buffer_pool_utilization
          value_type: FLOAT
          units: '%'
          params: |
            ( last(//mysql.innodb_buffer_pool_pages_total) - 
            last(//mysql.innodb_buffer_pool_pages_free) ) / 
            ( last(//mysql.innodb_buffer_pool_pages_total) + 
            ( last(//mysql.innodb_buffer_pool_pages_total) = 0 ) ) * 100 * 
            ( last(//mysql.innodb_buffer_pool_pages_total) > 0 )
          description: 'Ratio of used to total pages in the buffer pool.'
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: d785a37fe8d7484d9998e47e0e1d741f
              expression: 'max(/MySQL by Zabbix agent 2/mysql.buffer_pool_utilization,5m)<{$MYSQL.BUFF_UTIL.MIN.WARN}'
              name: 'MySQL: Buffer pool utilization is too low'
              event_name: 'MySQL: Buffer pool utilization is too low (less than {$MYSQL.BUFF_UTIL.MIN.WARN}% for 5m)'
              priority: WARNING
              description: 'The buffer pool utilization is less than `{$MYSQL.BUFF_UTIL.MIN.WARN}`% in the last 5 minutes. This means that there is a lot of unused RAM allocated for the buffer pool, which you can easily reallocate at the moment.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 1501b3b4d2b143378d162bd88ab70504
          name: 'Bytes received'
          type: DEPENDENT
          key: mysql.bytes_received.rate
          value_type: FLOAT
          units: Bps
          description: 'Number of bytes received from all clients.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Bytes_received
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: network
        - uuid: 0af5a1b506ef4f348a11757cea440a05
          name: 'Bytes sent'
          type: DEPENDENT
          key: mysql.bytes_sent.rate
          value_type: FLOAT
          units: Bps
          description: 'Number of bytes sent to all clients.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Bytes_sent
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: network
        - uuid: 0ebaced7ea3a4d9d9091128a8b0f6c49
          name: 'Command Delete per second'
          type: DEPENDENT
          key: mysql.com_delete.rate
          value_type: FLOAT
          description: 'The `Com_delete` counter variable indicates the number of times the `DELETE` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Com_delete
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: operations
        - uuid: cc5aeff5d46c43259b7a8d0ca3296e8a
          name: 'Command Insert per second'
          type: DEPENDENT
          key: mysql.com_insert.rate
          value_type: FLOAT
          description: 'The `Com_insert` counter variable indicates the number of times the `INSERT` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Com_insert
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: operations
        - uuid: e50d21a5d6764626a1eb3eb9f15dbc61
          name: 'Command Select per second'
          type: DEPENDENT
          key: mysql.com_select.rate
          value_type: FLOAT
          description: 'The `Com_select` counter variable indicates the number of times the `SELECT` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Com_select
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: operations
        - uuid: 6ce28af307b54a75817536105a14d80b
          name: 'Command Update per second'
          type: DEPENDENT
          key: mysql.com_update.rate
          value_type: FLOAT
          description: 'The `Com_update` counter variable indicates the number of times the `UPDATE` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Com_update
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: operations
        - uuid: aeb1cc1b7c1d47acb8788e3751bd0e6f
          name: 'Connections per second'
          type: DEPENDENT
          key: mysql.connections.rate
          value_type: FLOAT
          description: 'Number of connection attempts (successful or not) to the MySQL server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connections
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: dd9a33e71dd8468a9e4f2e25d3028a88
          name: 'Connection errors accept per second'
          type: DEPENDENT
          key: mysql.connection_errors_accept.rate
          value_type: FLOAT
          description: 'Number of errors that occurred during calls to `accept()` on the listening port.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_accept
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 12627c45088c4ed6a69c743ddf12e42e
          name: 'Connection errors internal per second'
          type: DEPENDENT
          key: mysql.connection_errors_internal.rate
          value_type: FLOAT
          description: 'Number of refused connections due to internal server errors, for example, out of memory errors, or failed thread starts.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_internal
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 1ad00e1a8a984254bec89c75a2d57ea0
          name: 'Connection errors max connections per second'
          type: DEPENDENT
          key: mysql.connection_errors_max_connections.rate
          value_type: FLOAT
          description: 'Number of refused connections due to the `max_connections` limit being reached.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_max_connections
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: 15cd0177e955459ba0862425755583a0
              expression: 'last(/MySQL by Zabbix agent 2/mysql.connection_errors_max_connections.rate)>0'
              name: 'MySQL: Refused connections'
              event_name: 'MySQL: Refused connections (max_connections limit reached)'
              priority: AVERAGE
              description: 'Number of refused connections due to the `max_connections` limit being reached.'
              tags:
                - tag: scope
                  value: availability
        - uuid: fbabb9b53f754cf6be0f657e90897bd9
          name: 'Connection errors peer address per second'
          type: DEPENDENT
          key: mysql.connection_errors_peer_address.rate
          value_type: FLOAT
          description: 'Number of errors while searching for the connecting client''s IP address.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_peer_address
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 48a2a6533ca4412d86e9f85fd748ad3b
          name: 'Connection errors select per second'
          type: DEPENDENT
          key: mysql.connection_errors_select.rate
          value_type: FLOAT
          description: 'Number of errors during calls to `select()` or `poll()` on the listening port. The client would not necessarily have been rejected in these cases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_select
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 6a32e65b2e1a43bbaf718a0962271efe
          name: 'Connection errors tcpwrap per second'
          type: DEPENDENT
          key: mysql.connection_errors_tcpwrap.rate
          value_type: FLOAT
          description: 'Number of connections the libwrap library has refused.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_tcpwrap
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: aaf0c77bf1b647e09633db28480ddfd7
          name: 'Created tmp tables on disk per second'
          type: DEPENDENT
          key: mysql.created_tmp_disk_tables.rate
          value_type: FLOAT
          description: 'Number of internal on-disk temporary tables created by the server while executing statements.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Created_tmp_disk_tables
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: storage
            - tag: component
              value: tables
          triggers:
            - uuid: 8c4e0c429c8241e28b930bfce7e29be8
              expression: 'min(/MySQL by Zabbix agent 2/mysql.created_tmp_disk_tables.rate,5m)>{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN}'
              name: 'MySQL: Number of on-disk temporary tables created per second is high'
              event_name: 'MySQL: Number of on-disk temporary tables created per second is high (over {$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 970c9a50e7304c4eb81c46f4456c3350
          name: 'Created tmp files on disk per second'
          type: DEPENDENT
          key: mysql.created_tmp_files.rate
          value_type: FLOAT
          description: 'How many temporary files `mysqld` has created.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Created_tmp_files
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 322b61acd92e46f787e96486d2553886
              expression: 'min(/MySQL by Zabbix agent 2/mysql.created_tmp_files.rate,5m)>{$MYSQL.CREATED_TMP_FILES.MAX.WARN}'
              name: 'MySQL: Number of temporary files created per second is high'
              event_name: 'MySQL: Number of temporary files created per second is high (over {$MYSQL.CREATED_TMP_FILES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: fef23a9c80e84d87803f3540277ade1e
          name: 'Created tmp tables on memory per second'
          type: DEPENDENT
          key: mysql.created_tmp_tables.rate
          value_type: FLOAT
          description: 'Number of internal temporary tables created by the server while executing statements.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Created_tmp_tables
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: tables
          triggers:
            - uuid: 86ed19d4ddc84f0da4a77c1dcbdf8c60
              expression: 'min(/MySQL by Zabbix agent 2/mysql.created_tmp_tables.rate,5m)>{$MYSQL.CREATED_TMP_TABLES.MAX.WARN}'
              name: 'MySQL: Number of internal temporary tables created per second is high'
              event_name: 'MySQL: Number of internal temporary tables created per second is high (over {$MYSQL.CREATED_TMP_TABLES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: a18b1092c42a4560abac7af42b14f007
          name: 'Get status variables'
          key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          history: '0'
          value_type: TEXT
          description: 'Gets server global status information.'
          tags:
            - tag: component
              value: raw
        - uuid: 51ab15a1c63348e48e6a75ed4e0ab5e3
          name: 'InnoDB buffer pool pages free'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_pages_free
          description: 'The total size of the InnoDB buffer pool, in pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_pages_free
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 14a8ea7cda164240bc7360454b4cd690
          name: 'InnoDB buffer pool pages total'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_pages_total
          description: 'The total size of the InnoDB buffer pool, in pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_pages_total
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 2b017cf20cb5412fa4e39dc9b4469930
          name: 'InnoDB buffer pool reads'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_reads
          description: 'Number of logical reads that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_reads
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 0f2b813c8d6740d783504055dcd9a9dc
          name: 'InnoDB buffer pool reads per second'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_reads.rate
          value_type: FLOAT
          description: 'Number of logical reads per second that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_reads
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: ab450aaa081d4a8d9db5dfd327d3b439
          name: 'InnoDB buffer pool read requests'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_read_requests
          description: 'Number of logical read requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_read_requests
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: dbf5bd4d705744bcb185e5044ff219e9
          name: 'InnoDB buffer pool read requests per second'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_read_requests.rate
          value_type: FLOAT
          description: 'Number of logical read requests per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_read_requests
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 3ab113998cec43da9bb702f5894d7b24
          name: 'Innodb buffer pool wait free'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_wait_free
          value_type: FLOAT
          description: 'Number of times InnoDB waited for a free page before reading or creating a page. Normally, writes to the InnoDB buffer pool happen in the background. When no clean pages are available, dirty pages are flushed first in order to free some up. This counts the numbers of wait for this operation to finish. If this value is not small, look at the increasing `innodb_buffer_pool_size`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_wait_free
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: e35cf67b6d2f44ffae908296faccfa50
          name: 'Calculated value of innodb_log_file_size'
          type: CALCULATED
          key: mysql.innodb_log_file_size
          value_type: FLOAT
          params: '(last(//mysql.innodb_os_log_written) - last(//mysql.innodb_os_log_written,#1:now-1h)) / {$MYSQL.INNODB_LOG_FILES}'
          description: '`Innodb_log_file_size` is calculated as: (`innodb_os_log_written`-`innodb_os_log_written`(time shift -1h))/`{$MYSQL.INNODB_LOG_FILES}`. `Innodb_log_file_size` is the size in bytes of the each InnoDB redo log file in the log group. The combined size can be no more than 512 GB. Larger values mean less disk I/O due to less flushing checkpoint activity, but also slower recovery from a crash.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          tags:
            - tag: component
              value: system
        - uuid: 2c1cba2399ab4b349e9751252c000b95
          name: 'Innodb number open files'
          type: DEPENDENT
          key: mysql.innodb_num_open_files
          value_type: FLOAT
          description: 'Number of open files held by InnoDB. InnoDB only.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_num_open_files
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: system
        - uuid: 6a4c63c40fb042868d2f23c86a0601a5
          name: 'Innodb log written'
          type: DEPENDENT
          key: mysql.innodb_os_log_written
          value_type: FLOAT
          units: B
          description: 'Number of bytes written to the InnoDB log.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_os_log_written
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: system
        - uuid: 60cbafe89a294f6fb24e3b9efe241bf5
          name: 'InnoDB row lock time'
          type: DEPENDENT
          key: mysql.innodb_row_lock_time
          value_type: FLOAT
          units: s
          description: 'The total time spent in acquiring row locks for InnoDB tables, in milliseconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_row_lock_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: 3827ee01c4434ff09555b4dba63bac47
          name: 'InnoDB row lock time max'
          type: DEPENDENT
          key: mysql.innodb_row_lock_time_max
          value_type: FLOAT
          units: s
          description: 'The maximum time to acquire a row lock for InnoDB tables, in milliseconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_row_lock_time_max
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: 4a849f57a32847ffb41a0e8a7e7735ce
          name: 'InnoDB row lock waits'
          type: DEPENDENT
          key: mysql.innodb_row_lock_waits
          description: 'Number of times operations on InnoDB tables had to wait for a row lock.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_row_lock_waits
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: afd9c494cc584ddd833298820d7beace
          name: 'Max used connections'
          type: DEPENDENT
          key: mysql.max_used_connections
          description: 'The maximum number of connections that have been in use simultaneously since the server start.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Max_used_connections
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: e766adca92fa47299b79e75d263437cc
          name: 'Open tables'
          type: DEPENDENT
          key: mysql.open_tables
          value_type: FLOAT
          description: 'Number of tables that are open.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Open_tables
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: tables
        - uuid: 26f839251a444e9abf83d4710718962a
          name: 'Open table definitions'
          type: DEPENDENT
          key: mysql.open_table_definitions
          value_type: FLOAT
          description: 'Number of cached table definitions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Open_table_definitions
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: tables
        - uuid: 8ca25701d88a4d33899a515d8e25dd5b
          name: Status
          key: 'mysql.ping["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          description: 'MySQL server status.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: 907a105ecee24eef9dd89598a42b6974
              expression: 'last(/MySQL by Zabbix agent 2/mysql.ping["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"])=0'
              name: 'MySQL: Service is down'
              priority: HIGH
              description: 'MySQL is down.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 345b2dd64d4041c7849aafc82cc63580
          name: 'Queries per second'
          type: DEPENDENT
          key: mysql.queries.rate
          value_type: FLOAT
          description: 'Number of statements executed by the server. This variable includes statements executed within stored programs, unlike the `Questions` variable.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Queries
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 73bc839df32e4d598f589a4a5440925e
          name: 'Questions per second'
          type: DEPENDENT
          key: mysql.questions.rate
          value_type: FLOAT
          description: 'Number of statements executed by the server. This includes only statements sent to the server by clients and not statements executed within stored programs, unlike the `Queries` variable.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Questions
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 0492b7b8c8464d0596c24dc877ba41e0
          name: 'Slow queries per second'
          type: DEPENDENT
          key: mysql.slow_queries.rate
          value_type: FLOAT
          description: 'Number of queries that have taken more than `long_query_time` seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Slow_queries
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: queries
          triggers:
            - uuid: 8ffcb17b0a644c5e8a2842b34d5713a8
              expression: 'min(/MySQL by Zabbix agent 2/mysql.slow_queries.rate,5m)>{$MYSQL.SLOW_QUERIES.MAX.WARN}'
              name: 'MySQL: Server has slow queries'
              event_name: 'MySQL: Server has slow queries (over {$MYSQL.SLOW_QUERIES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The number of slow queries is more than `{$MYSQL.SLOW_QUERIES.MAX.WARN}` in the last 5 minutes.'
              tags:
                - tag: scope
                  value: performance
        - uuid: de0edc0ab52b488681a597ba6bda3e9e
          name: 'Threads cached'
          type: DEPENDENT
          key: mysql.threads_cached
          description: 'Number of threads in the thread cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Threads_cached
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 6cd93969a80b4f738cd734764011b324
          name: 'Threads connected'
          type: DEPENDENT
          key: mysql.threads_connected
          description: 'Number of currently open connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Threads_connected
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: threads
        - uuid: eaab0b45e023459fa5c1e8b76e860431
          name: 'Threads created per second'
          type: DEPENDENT
          key: mysql.threads_created.rate
          value_type: FLOAT
          description: 'Number of threads created to handle connections. If the value of `Threads_created` is large, you may want to increase the `thread_cache_size` value. The cache miss rate can be calculated as `Threads_created`/`Connections`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Threads_created
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: threads
        - uuid: c4258eb3d8db4f30bc29dc531c5276a2
          name: 'Threads running'
          type: DEPENDENT
          key: mysql.threads_running
          description: 'Number of threads that are not sleeping.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Threads_running
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 1f3a71e74d8e42a1b539d67b4fc18531
          name: Uptime
          type: DEPENDENT
          key: mysql.uptime
          units: uptime
          description: 'Number of seconds that the server has been up.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Uptime
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 6f4edf8bfca0477b8b28a8ff811476b3
              expression: 'nodata(/MySQL by Zabbix agent 2/mysql.uptime,30m)=1'
              name: 'MySQL: Failed to fetch info data'
              event_name: 'MySQL: Failed to fetch info data (or no data for 30m)'
              priority: INFO
              description: 'Zabbix has not received any data for items for the last 30 minutes.'
              dependencies:
                - name: 'MySQL: Service is down'
                  expression: 'last(/MySQL by Zabbix agent 2/mysql.ping["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"])=0'
              tags:
                - tag: scope
                  value: availability
            - uuid: db5159889cb94f27840e6f4974ee5c0e
              expression: 'last(/MySQL by Zabbix agent 2/mysql.uptime)<10m'
              name: 'MySQL: Service has been restarted'
              event_name: 'MySQL: Service has been restarted (uptime < 10m)'
              priority: INFO
              description: 'MySQL uptime is less than 10 minutes.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 8058b068b90748fea464443058103fc8
          name: Version
          key: 'mysql.version["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          delay: 15m
          value_type: CHAR
          description: 'MySQL server version.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: e22c2e2213d74df98d344a95c8a96b6d
              expression: 'last(/MySQL by Zabbix agent 2/mysql.version["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"],#1)<>last(/MySQL by Zabbix agent 2/mysql.version["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"],#2) and length(last(/MySQL by Zabbix agent 2/mysql.version["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]))>0'
              name: 'MySQL: Version has changed'
              event_name: 'MySQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              description: 'The MySQL version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
      discovery_rules:
        - uuid: 49cbb331980040908673ceb2706d9542
          name: 'Database discovery'
          key: 'mysql.db.discovery["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          delay: 1h
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DATABASE}'
                value: '{$MYSQL.DBNAME.MATCHES}'
              - macro: '{#DATABASE}'
                value: '{$MYSQL.DBNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Scanning databases in DBMS.'
          item_prototypes:
            - uuid: e3e3c31483e94be2bd24b062bb049027
              name: 'Size of database {#DATABASE}'
              key: 'mysql.db.size["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#DATABASE}"]'
              delay: 5m
              units: B
              description: 'Database size.'
              preprocessing:
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DATABASE}'
          lld_macro_paths:
            - lld_macro: '{#DATABASE}'
              path: $.Database
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: 15035186d4d54962bc6b82ebbaea8784
          name: 'MariaDB discovery'
          type: DEPENDENT
          key: mysql.extra_metric.discovery
          description: 'Used for additional metrics if MariaDB is used.'
          item_prototypes:
            - uuid: c7ff129277134d86923dfb10e6d67928
              name: 'Binlog commits'
              type: DEPENDENT
              key: 'mysql.binlog_commits[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of transactions committed to the binary log.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Binlog_commits
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 07b27817a20244d68f2609c43aea1dea
              name: 'Binlog group commits'
              type: DEPENDENT
              key: 'mysql.binlog_group_commits[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of group commits done to the binary log.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Binlog_group_commits
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 152c4219a8d14812a813a250c6f17071
              name: 'Master GTID wait count'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_count[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The number of times `MASTER_GTID_WAIT` called.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Master_gtid_wait_count
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 3f13ee12a3db4933804c103ebfb170c9
              name: 'Master GTID wait timeouts'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_timeouts[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of timeouts occurring in `MASTER_GTID_WAIT`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Master_gtid_wait_timeouts
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 6ed43548a190425a83fce15b84b3ec87
              name: 'Master GTID wait time'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_time[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of time spent in `MASTER_GTID_WAIT`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Master_gtid_wait_time
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: transactions
          master_item:
            key: 'mysql.version["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return JSON.stringify(value.search(''MariaDB'')>-1 ? [{''{#SINGLETON}'': ''''}] : []);'
        - uuid: 59cd0d5f67e441f7ad3627233ab6b595
          name: 'Replication discovery'
          key: 'mysql.replication.discovery["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          delay: 1h
          description: 'If "show slave status" returns Master_Host, "Replication: *" items are created.'
          item_prototypes:
            - uuid: 130d6421b7864444a083dc7ffb1c03c5
              name: 'Replication Slave status {#MASTER_HOST}'
              key: 'mysql.replication.get_slave_status["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#MASTER_HOST}"]'
              history: '0'
              value_type: TEXT
              description: 'The item gets status information on the essential parameters of the slave threads.'
              tags:
                - tag: component
                  value: raw
            - uuid: bdbd657020b24a14a771a29a8a945a2b
              name: 'Replication Seconds Behind Master {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.replication.seconds_behind_master["{#MASTER_HOST}"]'
              units: s
              description: |
                Number of seconds that the slave SQL thread is behind processing the master binary log.
                A high number (or an increasing one) can indicate that the slave is unable to handle events
                from the master in a timely fashion.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Seconds_Behind_Master
                - type: MATCHES_REGEX
                  parameters:
                    - \d+
                  error_handler: CUSTOM_ERROR
                  error_handler_params: 'Replication is not performed.'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.replication.get_slave_status["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: 373e215000a64e05b0379f186141067f
                  expression: 'min(/MySQL by Zabbix agent 2/mysql.replication.seconds_behind_master["{#MASTER_HOST}"],5m)>{$MYSQL.REPL_LAG.MAX.WARN}'
                  name: 'MySQL: Replication lag is too high'
                  event_name: 'MySQL: Replication lag is too high (over {$MYSQL.REPL_LAG.MAX.WARN} for 5m)'
                  priority: WARNING
                  description: 'Replication delay is too long.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 2a5eb9d62cd046138d7564aa22b9ca33
              name: 'Replication Slave IO Running {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.replication.slave_io_running["{#MASTER_HOST}"]'
              value_type: CHAR
              description: |
                Whether the I/O thread for reading the master's binary log is running.
                Normally, you want this to be Yes unless you have not yet started a replication or have
                explicitly stopped it with STOP SLAVE.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Slave_IO_Running
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.replication.get_slave_status["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: efe46a25a1fd48e1a7504a9b06c26aee
                  expression: 'count(/MySQL by Zabbix agent 2/mysql.replication.slave_io_running["{#MASTER_HOST}"],#1,"ne","Yes")=1'
                  name: 'MySQL: The slave I/O thread is not connected to a replication master'
                  priority: WARNING
                  description: 'Whether the slave I/O thread is connected to the master.'
                  dependencies:
                    - name: 'MySQL: The slave I/O thread is not running'
                      expression: 'count(/MySQL by Zabbix agent 2/mysql.replication.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  tags:
                    - tag: scope
                      value: availability
                - uuid: 369f7ade45cd4ca39f5aa47d638e5e00
                  expression: 'count(/MySQL by Zabbix agent 2/mysql.replication.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  name: 'MySQL: The slave I/O thread is not running'
                  priority: AVERAGE
                  description: 'Whether the I/O thread for reading the master''s binary log is running.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 4fbb3cb164064694b37924dfcbaf2271
              name: 'Replication Slave SQL Running {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.replication.slave_sql_running["{#MASTER_HOST}"]'
              value_type: CHAR
              description: |
                Whether the SQL thread for executing events in the relay log is running.
                As with the I/O thread, this should normally be Yes.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Slave_SQL_Running
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.replication.get_slave_status["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: 9099f769af4c4008a69098f9e9f63673
                  expression: 'count(/MySQL by Zabbix agent 2/mysql.replication.slave_sql_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  name: 'MySQL: The SQL thread is not running'
                  priority: WARNING
                  description: 'Whether the SQL thread for executing events in the relay log is running.'
                  dependencies:
                    - name: 'MySQL: The slave I/O thread is not running'
                      expression: 'count(/MySQL by Zabbix agent 2/mysql.replication.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: bb79eaa9fc0d45e7b323a34d0c3f03cf
              name: 'Replication Slave SQL Running State {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.replication.slave_sql_running_state["{#MASTER_HOST}"]'
              value_type: TEXT
              description: 'This shows the state of the SQL driver threads.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Slave_SQL_Running_State
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.replication.get_slave_status["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
          lld_macro_paths:
            - lld_macro: '{#MASTER_HOST}'
              path: $.Master_Host
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: mysql
      macros:
        - macro: '{$MYSQL.ABORTED_CONN.MAX.WARN}'
          value: '3'
          description: 'Number of failed attempts to connect to the MySQL server for trigger expressions.'
          config:
            type: TEXT
            priority: '4'
            section_name: Thresholds
            label: 'Number of failed attempts to connect threshold'
            description: 'Threshold for the maximum number of failed attempts to connect to the MySQL server. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.BUFF_UTIL.MIN.WARN}'
          value: '50'
          description: 'The minimum buffer pool utilization in percentage for trigger expressions.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Buffer pool utilization threshold'
            description: 'Threshold of the minimum percentage of buffer pool utilization. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN}'
          value: '10'
          description: 'The maximum number of temporary tables created on a disk per second for trigger expressions.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Temporary tables created on a disk per second threshold'
            description: 'Threshold for the maximum number of temporary tables created on a disk per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_FILES.MAX.WARN}'
          value: '10'
          description: 'The maximum number of temporary files created on a disk per second for trigger expressions.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'Temporary files created on a disk per second threshold'
            description: 'Threshold for the maximum number of temporary files created on a disk per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_TABLES.MAX.WARN}'
          value: '30'
          description: 'The maximum number of temporary tables created in memory per second for trigger expressions.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Temporary tables created in memory per second threshold'
            description: 'Threshold for the maximum number of temporary tables created in memory per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.DBNAME.MATCHES}'
          value: .+
          description: 'Filter of discoverable databases.'
          config:
            type: TEXT
            priority: '12'
            section_name: Filters
            label: 'Include database filter'
            description: 'Regex string to include discovered database by its name.'
        - macro: '{$MYSQL.DBNAME.NOT_MATCHES}'
          value: information_schema
          description: 'Filter to exclude discovered databases.'
          config:
            type: TEXT
            priority: '13'
            section_name: Filters
            label: 'Exclude database filter'
            description: 'Regex string to exclude discovered database by its name.'
        - macro: '{$MYSQL.DSN}'
          description: 'System data source name such as <tcp://host:port or unix:/path/to/socket)/>.'
          config:
            type: TEXT
            priority: '1'
            label: 'MySQL DSN'
            description: 'Data source name of the MySQL instance.'
            required: 'YES'
        - macro: '{$MYSQL.INNODB_LOG_FILES}'
          value: '2'
          description: 'Number of physical files in the InnoDB redo log for calculating `innodb_log_file_size`.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'InnoDB redo log files number (for calculating)'
            description: 'Threshold for the maximum number of physical files in the InnoDB redo log for calculating `innodb_log_file_size`. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.PASSWORD}'
          type: SECRET_TEXT
          description: 'MySQL user password.'
          config:
            type: TEXT
            priority: '3'
            label: 'MySQL password'
            required: 'YES'
        - macro: '{$MYSQL.REPL_LAG.MAX.WARN}'
          value: 30m
          description: 'Amount of time the slave is behind the master for trigger expressions.'
          config:
            type: TEXT
            priority: '5'
            section_name: Thresholds
            label: 'Replication lag threshold'
            description: 'Threshold of the maximum time the slave is behind the master.'
        - macro: '{$MYSQL.SLOW_QUERIES.MAX.WARN}'
          value: '3'
          description: 'Number of slow queries for trigger expressions.'
          config:
            type: TEXT
            priority: '6'
            section_name: Thresholds
            label: 'Number of slow queries threshold'
            description: 'Threshold for the maximum number of slow queries. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.USER}'
          description: 'MySQL user name.'
          config:
            type: TEXT
            priority: '2'
            label: 'MySQL user'
            required: 'YES'
      dashboards:
        - uuid: ca5006123e0f4eb8bc0155027e663d2c
          name: 'MySQL performance'
          pages:
            - widgets:
                - type: graph
                  name: 'MySQL: Operations'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2'
                        name: 'MySQL: Operations'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'MySQL: Connections'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2'
                        name: 'MySQL: Connections'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  name: 'MySQL: InnoDB buffer pool'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2'
                        name: 'MySQL: InnoDB buffer pool'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graph
                  name: 'MySQL: Queries'
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2'
                        name: 'MySQL: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: 'MySQL: Bandwidth'
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2'
                        name: 'MySQL: Bandwidth'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  name: 'MySQL: Threads'
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2'
                        name: 'MySQL: Threads'
                    - type: STRING
                      name: reference
                      value: AAAAF
      valuemaps:
        - uuid: f2e8233fcf0a4dd2b53a82ca48436a88
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: 51ffd432b9324ce2b04e1d4dc4122d16
      template: 'MySQL by Zabbix agent 2 active'
      name: 'MySQL by Zabbix agent 2 active'
      description: |
        Requirements for template operation:
        
        1. Create a MySQL user for monitoring. For example:
        
        CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
        
        For more information please read the MySQL documentation https://dev.mysql.com/doc/refman/8.0/en/grant.html.
        
        NOTE: In order to collect replication metrics, MariaDB Enterprise Server 10.5.8-5 and above and MariaDB Community Server 10.5.9 and above require the SLAVE MONITOR privilege to be set for the monitoring user:
        
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW,SLAVE MONITOR ON *.* TO 'zbx_monitor'@'%';
        
        For more information please read the MariaDB documentation https://mariadb.com/docs/server/ref/mdb/privileges/SLAVE_MONITOR/
        
        2. Set in the {$MYSQL.DSN} macro the data source name of the MySQL instance either session name from Zabbix agent 2 configuration file or URI.
        Examples: MySQL1, tcp://localhost:3306, tcp://172.16.0.10, unix:/var/run/mysql.sock
        For more information about MySQL Unix socket file please read the MySQL documentation https://dev.mysql.com/doc/refman/8.0/en/problems-with-mysql-sock.html.
        
        3. If you had set URI in the {$MYSQL.DSN}, please define the user name and password in host macros ({$MYSQL.USER} and {$MYSQL.PASSWORD}).
        Leave macros {$MYSQL.USER} and {$MYSQL.PASSWORD} empty if you use a session name. Set the user name and password in the Plugins.Mysql.<...> section of your Zabbix agent 2 configuration file.
        For more information about configuring the Zabbix MySQL plugin please read the documentation https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/src/go/plugins/mysql/README.md.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384189-discussion-thread-for-official-zabbix-template-db-mysql
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        1. Create a MySQL user for monitoring (`<password>` at your discretion):
        
        ```text
        CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
        ```
        
        For more information, please see MySQL documentation https://dev.mysql.com/doc/refman/8.0/en/grant.html
        
        **NOTE:** In order to collect replication metrics, MariaDB Enterprise Server 10.5.8-5 and above and MariaDB Community Server 10.5.9 and above require the `SLAVE MONITOR` privilege to be set for the monitoring user:
        
        ```text
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW,SLAVE MONITOR ON *.* TO 'zbx_monitor'@'%';
        ```
        
        For more information please read the MariaDB documentation https://mariadb.com/docs/server/ref/mdb/privileges/SLAVE_MONITOR/
        
        2. Set in the `MySQL DSN` host wizard configuration field macro the data source name of the MySQL instance either session name from Zabbix agent 2 configuration file or URI.
        **Examples:** MySQL1, tcp://localhost:3306, tcp://172.16.0.10, unix:/var/run/mysql.sock
        For more information about MySQL Unix socket file, see the MySQL documentation https://dev.mysql.com/doc/refman/8.0/en/problems-with-mysql-sock.html.
        
        3. If you had set URI in the `MySQL DSN` field, define the user name and password in `MySQL user` and `MySQL password` host wizard configuration fields.
        Leave fields `MySQL user` and `MySQL password` empty if you use a session name. Set the user name and password in the Plugins.Mysql.<...> section of your Zabbix agent 2 configuration file.
        For more information about configuring the Zabbix MySQL plugin, see the documentation https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/src/go/plugins/mysql/README.md.
      vendor:
        name: Zabbix
        version: 7.4-3
      groups:
        - name: Templates/Databases
      items:
        - uuid: 2c14889cb9c7426390652828687551a9
          name: 'Aborted clients per second'
          type: DEPENDENT
          key: mysql.aborted_clients.rate
          value_type: FLOAT
          description: 'Number of connections that were aborted because the client died without closing the connection properly.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Aborted_clients
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 038a2fd010bb45e18217a69c2af1607f
          name: 'Aborted connections per second'
          type: DEPENDENT
          key: mysql.aborted_connects.rate
          value_type: FLOAT
          description: 'Number of failed attempts to connect to the MySQL server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Aborted_connects
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: a8dbc39812ea4ce488dab64ee230c38c
              expression: 'min(/MySQL by Zabbix agent 2 active/mysql.aborted_connects.rate,5m)>{$MYSQL.ABORTED_CONN.MAX.WARN}'
              name: 'MySQL: Server has aborted connections'
              event_name: 'MySQL: Server has aborted connections (over {$MYSQL.ABORTED_CONN.MAX.WARN} for 5m)'
              priority: AVERAGE
              description: 'The number of failed attempts to connect to the MySQL server is more than `{$MYSQL.ABORTED_CONN.MAX.WARN}` in the last 5 minutes.'
              dependencies:
                - name: 'MySQL: Refused connections'
                  expression: 'last(/MySQL by Zabbix agent 2 active/mysql.connection_errors_max_connections.rate)>0'
              tags:
                - tag: scope
                  value: availability
        - uuid: ae06d3e7db1d4a8fb85cc65a3dc5e355
          name: 'Binlog cache disk use'
          type: DEPENDENT
          key: mysql.binlog_cache_disk_use
          value_type: FLOAT
          description: 'Number of transactions that used a temporary disk cache because they could not fit in the regular binary log cache, being larger than `binlog_cache_size`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Binlog_cache_disk_use
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 82d31eef03914d4abde2448691d89a7a
          name: 'Buffer pool efficiency'
          type: CALCULATED
          key: mysql.buffer_pool_efficiency
          value_type: FLOAT
          units: '%'
          params: |
            100 - (last(//mysql.innodb_buffer_pool_reads) / 
            ( last(//mysql.innodb_buffer_pool_read_requests) + 
            ( last(//mysql.innodb_buffer_pool_read_requests) = 0 ) ) * 100 * 
            ( last(//mysql.innodb_buffer_pool_read_requests) > 0 ))
          description: 'The item shows how effectively the buffer pool is serving reads.'
          tags:
            - tag: component
              value: memory
        - uuid: 9fa2d2ebecaa4ff4bf2ec01a68cdf2a2
          name: 'Buffer pool utilization'
          type: CALCULATED
          key: mysql.buffer_pool_utilization
          value_type: FLOAT
          units: '%'
          params: |
            ( last(//mysql.innodb_buffer_pool_pages_total) - 
            last(//mysql.innodb_buffer_pool_pages_free) ) / 
            ( last(//mysql.innodb_buffer_pool_pages_total) + 
            ( last(//mysql.innodb_buffer_pool_pages_total) = 0 ) ) * 100 * 
            ( last(//mysql.innodb_buffer_pool_pages_total) > 0 )
          description: 'Ratio of used to total pages in the buffer pool.'
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 69e652db80c145e4bf7a4d4e99e0cb35
              expression: 'max(/MySQL by Zabbix agent 2 active/mysql.buffer_pool_utilization,5m)<{$MYSQL.BUFF_UTIL.MIN.WARN}'
              name: 'MySQL: Buffer pool utilization is too low'
              event_name: 'MySQL: Buffer pool utilization is too low (less than {$MYSQL.BUFF_UTIL.MIN.WARN}% for 5m)'
              priority: WARNING
              description: 'The buffer pool utilization is less than `{$MYSQL.BUFF_UTIL.MIN.WARN}`% in the last 5 minutes. This means that there is a lot of unused RAM allocated for the buffer pool, which you can easily reallocate at the moment.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 632dbd84e6844ed397cf1b3ffc107960
          name: 'Bytes received'
          type: DEPENDENT
          key: mysql.bytes_received.rate
          value_type: FLOAT
          units: Bps
          description: 'Number of bytes received from all clients.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Bytes_received
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: network
        - uuid: 7ffc513ae6994a1aa5a3ed7f601255df
          name: 'Bytes sent'
          type: DEPENDENT
          key: mysql.bytes_sent.rate
          value_type: FLOAT
          units: Bps
          description: 'Number of bytes sent to all clients.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Bytes_sent
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: network
        - uuid: 64a7029760b94798a48333c456325059
          name: 'Command Delete per second'
          type: DEPENDENT
          key: mysql.com_delete.rate
          value_type: FLOAT
          description: 'The `Com_delete` counter variable indicates the number of times the `DELETE` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Com_delete
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: operations
        - uuid: a8c673bc3339494186bf53bf566c6b48
          name: 'Command Insert per second'
          type: DEPENDENT
          key: mysql.com_insert.rate
          value_type: FLOAT
          description: 'The `Com_insert` counter variable indicates the number of times the `INSERT` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Com_insert
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: operations
        - uuid: 5bbebf6e13c0428f89a599f4ff8110bf
          name: 'Command Select per second'
          type: DEPENDENT
          key: mysql.com_select.rate
          value_type: FLOAT
          description: 'The `Com_select` counter variable indicates the number of times the `SELECT` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Com_select
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: operations
        - uuid: c681dee803994e6790a7cee1400be6eb
          name: 'Command Update per second'
          type: DEPENDENT
          key: mysql.com_update.rate
          value_type: FLOAT
          description: 'The `Com_update` counter variable indicates the number of times the `UPDATE` statement has been executed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Com_update
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: operations
        - uuid: 7bad2c745fd44b2e8791ee134febf51f
          name: 'Connections per second'
          type: DEPENDENT
          key: mysql.connections.rate
          value_type: FLOAT
          description: 'Number of connection attempts (successful or not) to the MySQL server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connections
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 79fc34a7b0c0468c9b9848684ce8a91c
          name: 'Connection errors accept per second'
          type: DEPENDENT
          key: mysql.connection_errors_accept.rate
          value_type: FLOAT
          description: 'Number of errors that occurred during calls to `accept()` on the listening port.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_accept
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 7906ad745983463188ed4559d134c144
          name: 'Connection errors internal per second'
          type: DEPENDENT
          key: mysql.connection_errors_internal.rate
          value_type: FLOAT
          description: 'Number of refused connections due to internal server errors, for example, out of memory errors, or failed thread starts.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_internal
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 0280f2ad4fa84c408540492ef560b626
          name: 'Connection errors max connections per second'
          type: DEPENDENT
          key: mysql.connection_errors_max_connections.rate
          value_type: FLOAT
          description: 'Number of refused connections due to the `max_connections` limit being reached.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_max_connections
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: 4f4cdc4d19624598aaa68d18e13a45e4
              expression: 'last(/MySQL by Zabbix agent 2 active/mysql.connection_errors_max_connections.rate)>0'
              name: 'MySQL: Refused connections'
              event_name: 'MySQL: Refused connections (max_connections limit reached)'
              priority: AVERAGE
              description: 'Number of refused connections due to the `max_connections` limit being reached.'
              tags:
                - tag: scope
                  value: availability
        - uuid: a5140bb668234a048db647e4463f040c
          name: 'Connection errors peer address per second'
          type: DEPENDENT
          key: mysql.connection_errors_peer_address.rate
          value_type: FLOAT
          description: 'Number of errors while searching for the connecting client''s IP address.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_peer_address
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 99dcacb6e1b4443faacd3b1a5330d240
          name: 'Connection errors select per second'
          type: DEPENDENT
          key: mysql.connection_errors_select.rate
          value_type: FLOAT
          description: 'Number of errors during calls to `select()` or `poll()` on the listening port. The client would not necessarily have been rejected in these cases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_select
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: a6901afc9c0047f18f05e4a2bdbdea4e
          name: 'Connection errors tcpwrap per second'
          type: DEPENDENT
          key: mysql.connection_errors_tcpwrap.rate
          value_type: FLOAT
          description: 'Number of connections the libwrap library has refused.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Connection_errors_tcpwrap
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 59efa8c9e8914cbda8d6e02706ef9972
          name: 'Created tmp tables on disk per second'
          type: DEPENDENT
          key: mysql.created_tmp_disk_tables.rate
          value_type: FLOAT
          description: 'Number of internal on-disk temporary tables created by the server while executing statements.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Created_tmp_disk_tables
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: storage
            - tag: component
              value: tables
          triggers:
            - uuid: cc8af7c9017a4873a037b5a0a8f7ac5f
              expression: 'min(/MySQL by Zabbix agent 2 active/mysql.created_tmp_disk_tables.rate,5m)>{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN}'
              name: 'MySQL: Number of on-disk temporary tables created per second is high'
              event_name: 'MySQL: Number of on-disk temporary tables created per second is high (over {$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: f1a3a596911b49a8b8bf6f36dc375c41
          name: 'Created tmp files on disk per second'
          type: DEPENDENT
          key: mysql.created_tmp_files.rate
          value_type: FLOAT
          description: 'How many temporary files `mysqld` has created.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Created_tmp_files
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 92ef67f27f384dd899ddb2865e00273a
              expression: 'min(/MySQL by Zabbix agent 2 active/mysql.created_tmp_files.rate,5m)>{$MYSQL.CREATED_TMP_FILES.MAX.WARN}'
              name: 'MySQL: Number of temporary files created per second is high'
              event_name: 'MySQL: Number of temporary files created per second is high (over {$MYSQL.CREATED_TMP_FILES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 8d67d3f53b794179a025f0813f766199
          name: 'Created tmp tables on memory per second'
          type: DEPENDENT
          key: mysql.created_tmp_tables.rate
          value_type: FLOAT
          description: 'Number of internal temporary tables created by the server while executing statements.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Created_tmp_tables
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: tables
          triggers:
            - uuid: 1d927f1cbb3b4105accbaef3f0994f81
              expression: 'min(/MySQL by Zabbix agent 2 active/mysql.created_tmp_tables.rate,5m)>{$MYSQL.CREATED_TMP_TABLES.MAX.WARN}'
              name: 'MySQL: Number of internal temporary tables created per second is high'
              event_name: 'MySQL: Number of internal temporary tables created per second is high (over {$MYSQL.CREATED_TMP_TABLES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: b942938fd6564e3cbcc37c11f59b2bed
          name: 'Get status variables'
          type: ZABBIX_ACTIVE
          key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          history: '0'
          value_type: TEXT
          description: 'Gets server global status information.'
          tags:
            - tag: component
              value: raw
        - uuid: b0cf7faaf9e940abb7648c712963fc9e
          name: 'InnoDB buffer pool pages free'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_pages_free
          description: 'The total size of the InnoDB buffer pool, in pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_pages_free
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: d1f7a0c2bb584d67b49dc963885d1bbb
          name: 'InnoDB buffer pool pages total'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_pages_total
          description: 'The total size of the InnoDB buffer pool, in pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_pages_total
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 96687092654a4d8b9e06e81664d89c12
          name: 'InnoDB buffer pool reads'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_reads
          description: 'Number of logical reads that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_reads
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: fddcc5c8139241c8ba8b950ec4cf6b1c
          name: 'InnoDB buffer pool reads per second'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_reads.rate
          value_type: FLOAT
          description: 'Number of logical reads per second that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_reads
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 53f1325ca0804cee8c4dff0b0064e54a
          name: 'InnoDB buffer pool read requests'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_read_requests
          description: 'Number of logical read requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_read_requests
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 946215157bce49e388eede72c9f89c57
          name: 'InnoDB buffer pool read requests per second'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_read_requests.rate
          value_type: FLOAT
          description: 'Number of logical read requests per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_read_requests
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: f2962ff518834cc69c56f99f4387a6cb
          name: 'Innodb buffer pool wait free'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_wait_free
          value_type: FLOAT
          description: 'Number of times InnoDB waited for a free page before reading or creating a page. Normally, writes to the InnoDB buffer pool happen in the background. When no clean pages are available, dirty pages are flushed first in order to free some up. This counts the numbers of wait for this operation to finish. If this value is not small, look at the increasing `innodb_buffer_pool_size`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_buffer_pool_wait_free
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: c9e2183fde7d4fff96bd837c362c43e6
          name: 'Calculated value of innodb_log_file_size'
          type: CALCULATED
          key: mysql.innodb_log_file_size
          value_type: FLOAT
          params: '(last(//mysql.innodb_os_log_written) - last(//mysql.innodb_os_log_written,#1:now-1h)) / {$MYSQL.INNODB_LOG_FILES}'
          description: '`Innodb_log_file_size` is calculated as: (`innodb_os_log_written`-`innodb_os_log_written`(time shift -1h))/`{$MYSQL.INNODB_LOG_FILES}`. `Innodb_log_file_size` is the size in bytes of the each InnoDB redo log file in the log group. The combined size can be no more than 512 GB. Larger values mean less disk I/O due to less flushing checkpoint activity, but also slower recovery from a crash.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          tags:
            - tag: component
              value: system
        - uuid: 2f3c759f069c47a5bb7dd20f11d94cd4
          name: 'Innodb number open files'
          type: DEPENDENT
          key: mysql.innodb_num_open_files
          value_type: FLOAT
          description: 'Number of open files held by InnoDB. InnoDB only.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_num_open_files
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: system
        - uuid: a94b8d6e84254ac98141a5f173ca5ecc
          name: 'Innodb log written'
          type: DEPENDENT
          key: mysql.innodb_os_log_written
          value_type: FLOAT
          units: B
          description: 'Number of bytes written to the InnoDB log.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_os_log_written
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: system
        - uuid: 5b9c6129929b4d20b2f761709b8dc1a5
          name: 'InnoDB row lock time'
          type: DEPENDENT
          key: mysql.innodb_row_lock_time
          value_type: FLOAT
          units: s
          description: 'The total time spent in acquiring row locks for InnoDB tables, in milliseconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_row_lock_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: 75ee06905e604bdb94f168fa208dfb66
          name: 'InnoDB row lock time max'
          type: DEPENDENT
          key: mysql.innodb_row_lock_time_max
          value_type: FLOAT
          units: s
          description: 'The maximum time to acquire a row lock for InnoDB tables, in milliseconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_row_lock_time_max
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: 6c9472c9970641a2b1a6749e0a70b859
          name: 'InnoDB row lock waits'
          type: DEPENDENT
          key: mysql.innodb_row_lock_waits
          description: 'Number of times operations on InnoDB tables had to wait for a row lock.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Innodb_row_lock_waits
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: 297d5be6f5054d00b91648cfb94ea186
          name: 'Max used connections'
          type: DEPENDENT
          key: mysql.max_used_connections
          description: 'The maximum number of connections that have been in use simultaneously since the server start.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Max_used_connections
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 61a666fbb3eb489685c27c94c20c58ae
          name: 'Open tables'
          type: DEPENDENT
          key: mysql.open_tables
          value_type: FLOAT
          description: 'Number of tables that are open.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Open_tables
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: tables
        - uuid: baf1e71d09aa4f13a5426803406de58d
          name: 'Open table definitions'
          type: DEPENDENT
          key: mysql.open_table_definitions
          value_type: FLOAT
          description: 'Number of cached table definitions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Open_table_definitions
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: tables
        - uuid: 338507e500574423915f798234c7f239
          name: Status
          type: ZABBIX_ACTIVE
          key: 'mysql.ping["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          description: 'MySQL server status.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: 6fed4cabb4b349cd9a0f7e82e7706139
              expression: 'last(/MySQL by Zabbix agent 2 active/mysql.ping["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"])=0'
              name: 'MySQL: Service is down'
              priority: HIGH
              description: 'MySQL is down.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 4cc293c5b36a430694665f879fea7a21
          name: 'Queries per second'
          type: DEPENDENT
          key: mysql.queries.rate
          value_type: FLOAT
          description: 'Number of statements executed by the server. This variable includes statements executed within stored programs, unlike the `Questions` variable.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Queries
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 218105acd6fd473b958c02adf8329d6a
          name: 'Questions per second'
          type: DEPENDENT
          key: mysql.questions.rate
          value_type: FLOAT
          description: 'Number of statements executed by the server. This includes only statements sent to the server by clients and not statements executed within stored programs, unlike the `Queries` variable.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Questions
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 4c9f5e35a2e44265bd75b1268ee1cafb
          name: 'Slow queries per second'
          type: DEPENDENT
          key: mysql.slow_queries.rate
          value_type: FLOAT
          description: 'Number of queries that have taken more than `long_query_time` seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Slow_queries
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: queries
          triggers:
            - uuid: 28b12490a27641ce828ec4d2e80f81b6
              expression: 'min(/MySQL by Zabbix agent 2 active/mysql.slow_queries.rate,5m)>{$MYSQL.SLOW_QUERIES.MAX.WARN}'
              name: 'MySQL: Server has slow queries'
              event_name: 'MySQL: Server has slow queries (over {$MYSQL.SLOW_QUERIES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The number of slow queries is more than `{$MYSQL.SLOW_QUERIES.MAX.WARN}` in the last 5 minutes.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 6706352c0746437ab99b9b9b660b931d
          name: 'Threads cached'
          type: DEPENDENT
          key: mysql.threads_cached
          description: 'Number of threads in the thread cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Threads_cached
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 0fecd4e46e274ceb9aaddb10534cc8ff
          name: 'Threads connected'
          type: DEPENDENT
          key: mysql.threads_connected
          description: 'Number of currently open connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Threads_connected
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 39ebfa8d6dde4ed9a8b53bb166d9b65c
          name: 'Threads created per second'
          type: DEPENDENT
          key: mysql.threads_created.rate
          value_type: FLOAT
          description: 'Number of threads created to handle connections. If the value of `Threads_created` is large, you may want to increase the `thread_cache_size` value. The cache miss rate can be calculated as `Threads_created`/`Connections`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Threads_created
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: threads
        - uuid: a02ba173427b47f2a01ee456257db5e4
          name: 'Threads running'
          type: DEPENDENT
          key: mysql.threads_running
          description: 'Number of threads that are not sleeping.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Threads_running
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 051ba64b0da0464c866f8e0fd84cfe2d
          name: Uptime
          type: DEPENDENT
          key: mysql.uptime
          units: uptime
          description: 'Number of seconds that the server has been up.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Uptime
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 3449a131f65d44c487a3346529713dd2
              expression: 'nodata(/MySQL by Zabbix agent 2 active/mysql.uptime,30m)=1'
              name: 'MySQL: Failed to fetch info data'
              event_name: 'MySQL: Failed to fetch info data (or no data for 30m)'
              priority: INFO
              description: 'Zabbix has not received any data for items for the last 30 minutes.'
              dependencies:
                - name: 'MySQL: Service is down'
                  expression: 'last(/MySQL by Zabbix agent 2 active/mysql.ping["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"])=0'
              tags:
                - tag: scope
                  value: availability
            - uuid: f92226addbf14463aea5aedc4f7bf7d8
              expression: 'last(/MySQL by Zabbix agent 2 active/mysql.uptime)<10m'
              name: 'MySQL: Service has been restarted'
              event_name: 'MySQL: Service has been restarted (uptime < 10m)'
              priority: INFO
              description: 'MySQL uptime is less than 10 minutes.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 674df57b5295448c89a7265902cc94ec
          name: Version
          type: ZABBIX_ACTIVE
          key: 'mysql.version["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          delay: 15m
          value_type: CHAR
          description: 'MySQL server version.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 36ce1008736b4a109a060e1150fec15f
              expression: 'last(/MySQL by Zabbix agent 2 active/mysql.version["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"],#1)<>last(/MySQL by Zabbix agent 2 active/mysql.version["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"],#2) and length(last(/MySQL by Zabbix agent 2 active/mysql.version["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]))>0'
              name: 'MySQL: Version has changed'
              event_name: 'MySQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              description: 'The MySQL version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
      discovery_rules:
        - uuid: 1d8d7069e0064521b52b388e0c6bc0a7
          name: 'Database discovery'
          type: ZABBIX_ACTIVE
          key: 'mysql.db.discovery["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          delay: 1h
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DATABASE}'
                value: '{$MYSQL.DBNAME.MATCHES}'
              - macro: '{#DATABASE}'
                value: '{$MYSQL.DBNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Scanning databases in DBMS.'
          item_prototypes:
            - uuid: f69eb8da26de4abb92cec75161e703f3
              name: 'Size of database {#DATABASE}'
              type: ZABBIX_ACTIVE
              key: 'mysql.db.size["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#DATABASE}"]'
              delay: 5m
              units: B
              description: 'Database size.'
              preprocessing:
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DATABASE}'
          lld_macro_paths:
            - lld_macro: '{#DATABASE}'
              path: $.Database
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: 66b3fda765c64b79b66a1ce97a7d19e8
          name: 'MariaDB discovery'
          type: DEPENDENT
          key: mysql.extra_metric.discovery
          description: 'Used for additional metrics if MariaDB is used.'
          item_prototypes:
            - uuid: c0e3223f67014485ad5d56a174568f0b
              name: 'Binlog commits'
              type: DEPENDENT
              key: 'mysql.binlog_commits[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of transactions committed to the binary log.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Binlog_commits
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: b530d1b7fd7c485ab412358d362aba41
              name: 'Binlog group commits'
              type: DEPENDENT
              key: 'mysql.binlog_group_commits[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of group commits done to the binary log.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Binlog_group_commits
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: fd1d44c4dcf14ddda1da4687e2c3e2b6
              name: 'Master GTID wait count'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_count[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The number of times `MASTER_GTID_WAIT` called.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Master_gtid_wait_count
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: de68ab3003db47afa4714548d3dc0ff6
              name: 'Master GTID wait timeouts'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_timeouts[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of timeouts occurring in `MASTER_GTID_WAIT`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Master_gtid_wait_timeouts
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 1a2a6de9e9b3482780023b1375368b7d
              name: 'Master GTID wait time'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_time[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of time spent in `MASTER_GTID_WAIT`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Master_gtid_wait_time
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
              tags:
                - tag: component
                  value: transactions
          master_item:
            key: 'mysql.version["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return JSON.stringify(value.search(''MariaDB'')>-1 ? [{''{#SINGLETON}'': ''''}] : []);'
        - uuid: aaf6d2423fb34bef850be2d1be3fc36a
          name: 'Replication discovery'
          type: ZABBIX_ACTIVE
          key: 'mysql.replication.discovery["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}"]'
          delay: 1h
          description: 'If "show slave status" returns Master_Host, "Replication: *" items are created.'
          item_prototypes:
            - uuid: 6284876731214fb8bf51f09dd40cf5fe
              name: 'Replication Slave status {#MASTER_HOST}'
              type: ZABBIX_ACTIVE
              key: 'mysql.replication.get_slave_status["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#MASTER_HOST}"]'
              history: '0'
              value_type: TEXT
              description: 'The item gets status information on the essential parameters of the slave threads.'
              tags:
                - tag: component
                  value: raw
            - uuid: f8d25b5c73474a048f7998ec75784b2a
              name: 'Replication Seconds Behind Master {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.replication.seconds_behind_master["{#MASTER_HOST}"]'
              units: s
              description: |
                Number of seconds that the slave SQL thread is behind processing the master binary log.
                A high number (or an increasing one) can indicate that the slave is unable to handle events
                from the master in a timely fashion.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Seconds_Behind_Master
                - type: MATCHES_REGEX
                  parameters:
                    - \d+
                  error_handler: CUSTOM_ERROR
                  error_handler_params: 'Replication is not performed.'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.replication.get_slave_status["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: a2d2da0c7df54bbfba3b1f50306c51d2
                  expression: 'min(/MySQL by Zabbix agent 2 active/mysql.replication.seconds_behind_master["{#MASTER_HOST}"],5m)>{$MYSQL.REPL_LAG.MAX.WARN}'
                  name: 'MySQL: Replication lag is too high'
                  event_name: 'MySQL: Replication lag is too high (over {$MYSQL.REPL_LAG.MAX.WARN} for 5m)'
                  priority: WARNING
                  description: 'Replication delay is too long.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 9e0917199e5c4552ab84df0b6f7f590c
              name: 'Replication Slave IO Running {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.replication.slave_io_running["{#MASTER_HOST}"]'
              value_type: CHAR
              description: |
                Whether the I/O thread for reading the master's binary log is running.
                Normally, you want this to be Yes unless you have not yet started a replication or have
                explicitly stopped it with STOP SLAVE.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Slave_IO_Running
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.replication.get_slave_status["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: 82ace91dce1c45b688ed62c438613510
                  expression: 'count(/MySQL by Zabbix agent 2 active/mysql.replication.slave_io_running["{#MASTER_HOST}"],#1,"ne","Yes")=1'
                  name: 'MySQL: The slave I/O thread is not connected to a replication master'
                  priority: WARNING
                  description: 'Whether the slave I/O thread is connected to the master.'
                  dependencies:
                    - name: 'MySQL: The slave I/O thread is not running'
                      expression: 'count(/MySQL by Zabbix agent 2 active/mysql.replication.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  tags:
                    - tag: scope
                      value: availability
                - uuid: 3eab03819bb84d48bba973c7060dcada
                  expression: 'count(/MySQL by Zabbix agent 2 active/mysql.replication.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  name: 'MySQL: The slave I/O thread is not running'
                  priority: AVERAGE
                  description: 'Whether the I/O thread for reading the master''s binary log is running.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 438c4e34d77a43398503cf8ed5db034b
              name: 'Replication Slave SQL Running {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.replication.slave_sql_running["{#MASTER_HOST}"]'
              value_type: CHAR
              description: |
                Whether the SQL thread for executing events in the relay log is running.
                As with the I/O thread, this should normally be Yes.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Slave_SQL_Running
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.replication.get_slave_status["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: ee129bbeec9d42e1be803f58d0c6e1b9
                  expression: 'count(/MySQL by Zabbix agent 2 active/mysql.replication.slave_sql_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  name: 'MySQL: The SQL thread is not running'
                  priority: WARNING
                  description: 'Whether the SQL thread for executing events in the relay log is running.'
                  dependencies:
                    - name: 'MySQL: The slave I/O thread is not running'
                      expression: 'count(/MySQL by Zabbix agent 2 active/mysql.replication.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 2db5da5c9069492c8a513bcd39e8d6d9
              name: 'Replication Slave SQL Running State {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.replication.slave_sql_running_state["{#MASTER_HOST}"]'
              value_type: TEXT
              description: 'This shows the state of the SQL driver threads.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Slave_SQL_Running_State
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.replication.get_slave_status["{$MYSQL.DSN}","{$MYSQL.USER}","{$MYSQL.PASSWORD}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
          lld_macro_paths:
            - lld_macro: '{#MASTER_HOST}'
              path: $.Master_Host
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: mysql
      macros:
        - macro: '{$MYSQL.ABORTED_CONN.MAX.WARN}'
          value: '3'
          description: 'Number of failed attempts to connect to the MySQL server for trigger expressions.'
          config:
            type: TEXT
            priority: '4'
            section_name: Thresholds
            label: 'Number of failed attempts to connect threshold'
            description: 'Threshold for the maximum number of failed attempts to connect to the MySQL server. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.BUFF_UTIL.MIN.WARN}'
          value: '50'
          description: 'The minimum buffer pool utilization in percentage for trigger expressions.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Buffer pool utilization threshold'
            description: 'Threshold of the minimum percentage of buffer pool utilization. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN}'
          value: '10'
          description: 'The maximum number of temporary tables created on a disk per second for trigger expressions.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Temporary tables created on a disk per second threshold'
            description: 'Threshold for the maximum number of temporary tables created on a disk per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_FILES.MAX.WARN}'
          value: '10'
          description: 'The maximum number of temporary files created on a disk per second for trigger expressions.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'Temporary files created on a disk per second threshold'
            description: 'Threshold for the maximum number of temporary files created on a disk per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_TABLES.MAX.WARN}'
          value: '30'
          description: 'The maximum number of temporary tables created in memory per second for trigger expressions.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Temporary tables created in memory per second threshold'
            description: 'Threshold for the maximum number of temporary tables created in memory per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.DBNAME.MATCHES}'
          value: .+
          description: 'Filter of discoverable databases.'
          config:
            type: TEXT
            priority: '12'
            section_name: Filters
            label: 'Include database filter'
            description: 'Regex string to include discovered database by its name.'
        - macro: '{$MYSQL.DBNAME.NOT_MATCHES}'
          value: information_schema
          description: 'Filter to exclude discovered databases.'
          config:
            type: TEXT
            priority: '13'
            section_name: Filters
            label: 'Exclude database filter'
            description: 'Regex string to exclude discovered database by its name.'
        - macro: '{$MYSQL.DSN}'
          description: 'System data source name such as <tcp://host:port or unix:/path/to/socket)/>.'
          config:
            type: TEXT
            priority: '1'
            label: 'MySQL DSN'
            description: 'Data source name of the MySQL instance.'
            required: 'YES'
        - macro: '{$MYSQL.INNODB_LOG_FILES}'
          value: '2'
          description: 'Number of physical files in the InnoDB redo log for calculating `innodb_log_file_size`.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'InnoDB redo log files number (for calculating)'
            description: 'Threshold for the maximum number of physical files in the InnoDB redo log for calculating `innodb_log_file_size`. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.PASSWORD}'
          type: SECRET_TEXT
          description: 'MySQL user password.'
          config:
            type: TEXT
            priority: '3'
            label: 'MySQL password'
            required: 'YES'
        - macro: '{$MYSQL.REPL_LAG.MAX.WARN}'
          value: 30m
          description: 'Amount of time the slave is behind the master for trigger expressions.'
          config:
            type: TEXT
            priority: '5'
            section_name: Thresholds
            label: 'Replication lag threshold'
            description: 'Threshold of the maximum time the slave is behind the master.'
        - macro: '{$MYSQL.SLOW_QUERIES.MAX.WARN}'
          value: '3'
          description: 'Number of slow queries for trigger expressions.'
          config:
            type: TEXT
            priority: '6'
            section_name: Thresholds
            label: 'Number of slow queries threshold'
            description: 'Threshold for the maximum number of slow queries. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.USER}'
          description: 'MySQL user name.'
          config:
            type: TEXT
            priority: '2'
            label: 'MySQL user'
            required: 'YES'
      dashboards:
        - uuid: 403df820c4d3431ba3d2879f6025389e
          name: 'MySQL performance'
          pages:
            - widgets:
                - type: graph
                  name: 'MySQL: Operations'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2 active'
                        name: 'MySQL: Operations'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'MySQL: Connections'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2 active'
                        name: 'MySQL: Connections'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  name: 'MySQL: InnoDB buffer pool'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2 active'
                        name: 'MySQL: InnoDB buffer pool'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graph
                  name: 'MySQL: Queries'
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2 active'
                        name: 'MySQL: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: 'MySQL: Bandwidth'
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2 active'
                        name: 'MySQL: Bandwidth'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  name: 'MySQL: Threads'
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent 2 active'
                        name: 'MySQL: Threads'
                    - type: STRING
                      name: reference
                      value: AAAAF
      valuemaps:
        - uuid: 3592fb0098304d86ab35a6a86aa95ec5
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: 1ae69b01417849b180717f62ad7819d6
      template: 'MySQL by Zabbix agent active'
      name: 'MySQL by Zabbix agent active'
      description: |
        Requirements for template operation:
        
        1. Install Zabbix agent and MySQL client. If necessary, add the path to the 'mysql' and 'mysqladmin' utilities to the global environment variable PATH.
        
        2. Copy the 'template_db_mysql.conf' file with user parameters into folder with Zabbix agent configuration (/etc/zabbix/zabbix_agentd.d/ by default). Don't forget to restart Zabbix agent.
        
        3. Create the MySQL user that will be used for monitoring ('<password>' at your discretion). For example:
        
        CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
        
        For more information, please see MySQL documentation (https://dev.mysql.com/doc/refman/8.0/en/grant.html).
        
        NOTE: In order to collect replication metrics, MariaDB Enterprise Server 10.5.8-5 and above and MariaDB Community Server 10.5.9 and above require the SLAVE MONITOR privilege to be set for the monitoring user:
        
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW,SLAVE MONITOR ON *.* TO 'zbx_monitor'@'%';
        
        For more information, please read the MariaDB documentation (https://mariadb.com/docs/server/ref/mdb/privileges/SLAVE_MONITOR/).
        
        4. Create '.my.cnf' configuration file in the home directory of Zabbix agent for Linux distributions (/var/lib/zabbix by default) or 'my.cnf' in c:\ for Windows. For example:
        
        [client]
        protocol=tcp
        user='zbx_monitor'
        password='<password>'
        
        For more information, please see MySQL documentation (https://dev.mysql.com/doc/refman/8.0/en/option-files.html).
        
        NOTE: Linux distributions that use SELinux may require additional steps for access configuration.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384189-discussion-thread-for-official-zabbix-template-db-mysql
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        1. Install MySQL client. If necessary, add the path to the `mysql` and `mysqladmin` utilities to the global environment variable PATH.
        2. Copy the `template_db_mysql.conf` file with user parameters into folder with Zabbix agent configuration (/etc/zabbix/zabbix_agentd.d/ by default). Don't forget to restart Zabbix agent.
        3. Create the MySQL user that will be used for monitoring (`<password>` at your discretion). For example:
        
        ```text
        CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
        ```
        
        For more information, please see [`MySQL documentation`](https://dev.mysql.com/doc/refman/8.0/en/grant.html).
        
        4. Create `.my.cnf` configuration file in the home directory of Zabbix agent for Linux distributions (/var/lib/zabbix by default) or `my.cnf` in c:\ for Windows. For example:
        
        ```text
        [client]
        protocol=tcp
        user='zbx_monitor'
        password='<password>'
        ```
        
        For more information, please see [`MySQL documentation`](https://dev.mysql.com/doc/refman/8.0/en/option-files.html).
        
        **NOTE:** In order to collect replication metrics, MariaDB Enterprise Server 10.5.8-5 and above and MariaDB Community Server 10.5.9 and above require the `SLAVE MONITOR` privilege to be set for the monitoring user:
        
        ```text
        GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW,SLAVE MONITOR ON *.* TO 'zbx_monitor'@'%';
        ```
        
        For more information, please read the [`MariaDB documentation`](https://mariadb.com/docs/server/ref/mdb/privileges/SLAVE_MONITOR/).
        
        NOTE: Linux distributions that use SELinux may require additional steps for access configuration.
        
        For example, the following rule could be added to the SELinux policy:
        
        ```text
        # cat <<EOF > zabbix_home.te
        module zabbix_home 1.0;
        
        require {
                type zabbix_agent_t;
                type zabbix_var_lib_t;
                type mysqld_etc_t;
                type mysqld_port_t;
                type mysqld_var_run_t;
                class file { open read };
                class tcp_socket name_connect;
                class sock_file write;
        }
        
        #============= zabbix_agent_t ==============
        
        allow zabbix_agent_t zabbix_var_lib_t:file read;
        allow zabbix_agent_t zabbix_var_lib_t:file open;
        allow zabbix_agent_t mysqld_etc_t:file read;
        allow zabbix_agent_t mysqld_port_t:tcp_socket name_connect;
        allow zabbix_agent_t mysqld_var_run_t:sock_file write;
        EOF
        # checkmodule -M -m -o zabbix_home.mod zabbix_home.te
        # semodule_package -o zabbix_home.pp -m zabbix_home.mod
        # semodule -i zabbix_home.pp
        # restorecon -R /var/lib/zabbix
        ```
      vendor:
        name: Zabbix
        version: 7.4-3
      groups:
        - name: Templates/Databases
      items:
        - uuid: 92637d299d254e83b41df8f9893ecc37
          name: 'Aborted clients per second'
          type: DEPENDENT
          key: mysql.aborted_clients.rate
          value_type: FLOAT
          description: 'Number of connections that were aborted because the client died without closing the connection properly.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Aborted_clients'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 7ae8f8a1572346d38abe38491f8f5800
          name: 'Aborted connections per second'
          type: DEPENDENT
          key: mysql.aborted_connects.rate
          value_type: FLOAT
          description: 'Number of failed attempts to connect to the MySQL server.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Aborted_connects'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: f49998d4098348378c661927155cd6bf
              expression: 'min(/MySQL by Zabbix agent active/mysql.aborted_connects.rate,5m)>{$MYSQL.ABORTED_CONN.MAX.WARN}'
              name: 'MySQL: Server has aborted connections'
              event_name: 'MySQL: Server has aborted connections (over {$MYSQL.ABORTED_CONN.MAX.WARN} for 5m)'
              priority: AVERAGE
              description: 'The number of failed attempts to connect to the MySQL server is more than `{$MYSQL.ABORTED_CONN.MAX.WARN}` in the last 5 minutes.'
              dependencies:
                - name: 'MySQL: Refused connections'
                  expression: 'last(/MySQL by Zabbix agent active/mysql.connection_errors_max_connections.rate)>0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 2265406d17394c4a835d209d53d6c259
          name: 'Binlog cache disk use'
          type: DEPENDENT
          key: mysql.binlog_cache_disk_use
          value_type: FLOAT
          description: 'Number of transactions that used a temporary disk cache because they could not fit in the regular binary log cache, being larger than `binlog_cache_size`.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Binlog_cache_disk_use'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 6179105b341e41e892398649eec227bb
          name: 'Buffer pool efficiency'
          type: CALCULATED
          key: mysql.buffer_pool_efficiency
          value_type: FLOAT
          units: '%'
          params: |
            100 - (last(//mysql.innodb_buffer_pool_reads) / 
            ( last(//mysql.innodb_buffer_pool_read_requests) + 
            ( last(//mysql.innodb_buffer_pool_read_requests) = 0 ) ) * 100 * 
            ( last(//mysql.innodb_buffer_pool_read_requests) > 0 ))
          description: 'The item shows how effectively the buffer pool is serving reads.'
          tags:
            - tag: component
              value: memory
        - uuid: 427ee34312ca4fb595b71db9a350b1fc
          name: 'Buffer pool utilization'
          type: CALCULATED
          key: mysql.buffer_pool_utilization
          value_type: FLOAT
          units: '%'
          params: |
            ( last(//mysql.innodb_buffer_pool_pages_total) - 
            last(//mysql.innodb_buffer_pool_pages_free) ) / 
            ( last(//mysql.innodb_buffer_pool_pages_total) + 
            ( last(//mysql.innodb_buffer_pool_pages_total) = 0 ) ) * 100 * 
            ( last(//mysql.innodb_buffer_pool_pages_total) > 0 )
          description: 'Ratio of used to total pages in the buffer pool.'
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 254756ed1bcb4ae3b342d34b86e1b6fc
              expression: 'max(/MySQL by Zabbix agent active/mysql.buffer_pool_utilization,5m)<{$MYSQL.BUFF_UTIL.MIN.WARN}'
              name: 'MySQL: Buffer pool utilization is too low'
              event_name: 'MySQL: Buffer pool utilization is too low (less than {$MYSQL.BUFF_UTIL.MIN.WARN}% for 5m)'
              priority: WARNING
              description: 'The buffer pool utilization is less than `{$MYSQL.BUFF_UTIL.MIN.WARN}`% in the last 5 minutes. This means that there is a lot of unused RAM allocated for the buffer pool, which you can easily reallocate at the moment.'
              tags:
                - tag: scope
                  value: notice
        - uuid: e22c542460114c7a8877d6a4c56be2f2
          name: 'Bytes received'
          type: DEPENDENT
          key: mysql.bytes_received.rate
          value_type: FLOAT
          units: Bps
          description: 'Number of bytes received from all clients.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Bytes_received'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: network
        - uuid: 2b202ebdc9a546eaa794d61418783e8e
          name: 'Bytes sent'
          type: DEPENDENT
          key: mysql.bytes_sent.rate
          value_type: FLOAT
          units: Bps
          description: 'Number of bytes sent to all clients.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Bytes_sent'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: network
        - uuid: 776e1baca7eb43c693dc8b64552b76b4
          name: 'Command Delete per second'
          type: DEPENDENT
          key: mysql.com_delete.rate
          value_type: FLOAT
          description: 'The `Com_delete` counter variable indicates the number of times the `DELETE` statement has been executed.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Com_delete'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: operations
        - uuid: d8cda6ee6a5340739b65c0fb74986358
          name: 'Command Insert per second'
          type: DEPENDENT
          key: mysql.com_insert.rate
          value_type: FLOAT
          description: 'The `Com_insert` counter variable indicates the number of times the `INSERT` statement has been executed.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Com_insert'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: operations
        - uuid: 1782572b896c43bba77872f2d535dd1f
          name: 'Command Select per second'
          type: DEPENDENT
          key: mysql.com_select.rate
          value_type: FLOAT
          description: 'The `Com_select` counter variable indicates the number of times the `SELECT` statement has been executed.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Com_select'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: operations
        - uuid: 6a53476ac7b548098986dca948ab5395
          name: 'Command Update per second'
          type: DEPENDENT
          key: mysql.com_update.rate
          value_type: FLOAT
          description: 'The `Com_update` counter variable indicates the number of times the `UPDATE` statement has been executed.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Com_update'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: operations
        - uuid: 216667bd998a49b2b4edef82e3bdaa8b
          name: 'Connections per second'
          type: DEPENDENT
          key: mysql.connections.rate
          value_type: FLOAT
          description: 'Number of connection attempts (successful or not) to the MySQL server.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connections'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 259c94b73afe486284dae1b15998b305
          name: 'Connection errors accept per second'
          type: DEPENDENT
          key: mysql.connection_errors_accept.rate
          value_type: FLOAT
          description: 'Number of errors that occurred during calls to `accept()` on the listening port.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_accept'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 7213544faa5d4f0984646ebc2a596dba
          name: 'Connection errors internal per second'
          type: DEPENDENT
          key: mysql.connection_errors_internal.rate
          value_type: FLOAT
          description: 'Number of refused connections due to internal server errors, for example, out of memory errors, or failed thread starts.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_internal'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: b6af884a95e34404b4356a6cad0ea838
          name: 'Connection errors max connections per second'
          type: DEPENDENT
          key: mysql.connection_errors_max_connections.rate
          value_type: FLOAT
          description: 'Number of refused connections due to the `max_connections` limit being reached.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_max_connections'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: 8ce8e2bd4713435e83ccd036e84e1120
              expression: 'last(/MySQL by Zabbix agent active/mysql.connection_errors_max_connections.rate)>0'
              name: 'MySQL: Refused connections'
              event_name: 'MySQL: Refused connections (max_connections limit reached)'
              priority: AVERAGE
              description: 'Number of refused connections due to the `max_connections` limit being reached.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 05e63d8964814d808bfa2833bcdd446e
          name: 'Connection errors peer address per second'
          type: DEPENDENT
          key: mysql.connection_errors_peer_address.rate
          value_type: FLOAT
          description: 'Number of errors while searching for the connecting client''s IP address.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_peer_address'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: f43fd1f1c836446bb543b8f04e6ef564
          name: 'Connection errors select per second'
          type: DEPENDENT
          key: mysql.connection_errors_select.rate
          value_type: FLOAT
          description: 'Number of errors during calls to `select()` or `poll()` on the listening port. The client would not necessarily have been rejected in these cases.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_select'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: e1af6725de7e4fb0b3ec97fa1339e099
          name: 'Connection errors tcpwrap per second'
          type: DEPENDENT
          key: mysql.connection_errors_tcpwrap.rate
          value_type: FLOAT
          description: 'Number of connections the libwrap library has refused.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Connection_errors_tcpwrap'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 98f0e26ea13946ab9a1f277d22feece7
          name: 'Created tmp tables on disk per second'
          type: DEPENDENT
          key: mysql.created_tmp_disk_tables.rate
          value_type: FLOAT
          description: 'Number of internal on-disk temporary tables created by the server while executing statements.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Created_tmp_disk_tables'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: storage
            - tag: component
              value: tables
          triggers:
            - uuid: 5b6d0d6c7fee4fefb1ed58017818f223
              expression: 'min(/MySQL by Zabbix agent active/mysql.created_tmp_disk_tables.rate,5m)>{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN}'
              name: 'MySQL: Number of on-disk temporary tables created per second is high'
              event_name: 'MySQL: Number of on-disk temporary tables created per second is high (over {$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 2c330fcdea6b4993997db65ff0127e95
          name: 'Created tmp files on disk per second'
          type: DEPENDENT
          key: mysql.created_tmp_files.rate
          value_type: FLOAT
          description: 'How many temporary files `mysqld` has created.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Created_tmp_files'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 3c49bcc1e3e34d1ca6f1d1b5eeeeba9e
              expression: 'min(/MySQL by Zabbix agent active/mysql.created_tmp_files.rate,5m)>{$MYSQL.CREATED_TMP_FILES.MAX.WARN}'
              name: 'MySQL: Number of temporary files created per second is high'
              event_name: 'MySQL: Number of temporary files created per second is high (over {$MYSQL.CREATED_TMP_FILES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: e324565c8aef4acba33f1ccc65a1c087
          name: 'Created tmp tables on memory per second'
          type: DEPENDENT
          key: mysql.created_tmp_tables.rate
          value_type: FLOAT
          description: 'Number of internal temporary tables created by the server while executing statements.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Created_tmp_tables'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: tables
          triggers:
            - uuid: ef985e5db11a49139b0022aaf80cb2d5
              expression: 'min(/MySQL by Zabbix agent active/mysql.created_tmp_tables.rate,5m)>{$MYSQL.CREATED_TMP_TABLES.MAX.WARN}'
              name: 'MySQL: Number of internal temporary tables created per second is high'
              event_name: 'MySQL: Number of internal temporary tables created per second is high (over {$MYSQL.CREATED_TMP_TABLES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The application using the database may be in need of query optimization.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 202cc1174b7f4b63a8c90bdc54ec2bb2
          name: 'Get status variables'
          type: ZABBIX_ACTIVE
          key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          history: '0'
          value_type: TEXT
          description: 'Gets server global status information.'
          tags:
            - tag: component
              value: raw
        - uuid: 5551d764b45c4d33a91701aa8b2b5d4f
          name: 'InnoDB buffer pool pages free'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_pages_free
          description: 'The total size of the InnoDB buffer pool, in pages.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_pages_free'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: c7b4fc71c5d14e0f802e6a4c97c0a98b
          name: 'InnoDB buffer pool pages total'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_pages_total
          description: 'The total size of the InnoDB buffer pool, in pages.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_pages_total'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 2f05d6a246844924a5e03a615bf20373
          name: 'InnoDB buffer pool reads'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_reads
          description: 'Number of logical reads that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_reads'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 1655258df96645eea062c66bee146292
          name: 'InnoDB buffer pool reads per second'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_reads.rate
          value_type: FLOAT
          description: 'Number of logical reads per second that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_reads'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: a266591327664cddb056d9dc2e8de2c7
          name: 'InnoDB buffer pool read requests'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_read_requests
          description: 'Number of logical read requests.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_read_requests'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: a6b3a633cc0448859ef8b61763ccca1a
          name: 'InnoDB buffer pool read requests per second'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_read_requests.rate
          value_type: FLOAT
          description: 'Number of logical read requests per second.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_read_requests'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: ebbeed7d36604713b98677c3fc46a260
          name: 'Innodb buffer pool wait free'
          type: DEPENDENT
          key: mysql.innodb_buffer_pool_wait_free
          value_type: FLOAT
          description: 'Number of times InnoDB waited for a free page before reading or creating a page. Normally, writes to the InnoDB buffer pool happen in the background. When no clean pages are available, dirty pages are flushed first in order to free some up. This counts the numbers of wait for this operation to finish. If this value is not small, look at the increasing `innodb_buffer_pool_size`.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_buffer_pool_wait_free'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 8ce62d571e854df187d201bd4a7ccce1
          name: 'Calculated value of innodb_log_file_size'
          type: CALCULATED
          key: mysql.innodb_log_file_size
          value_type: FLOAT
          params: '(last(//mysql.innodb_os_log_written) - last(//mysql.innodb_os_log_written,#1:now-1h)) / {$MYSQL.INNODB_LOG_FILES}'
          description: '`Innodb_log_file_size` is calculated as: (`innodb_os_log_written`-`innodb_os_log_written`(time shift -1h))/`{$MYSQL.INNODB_LOG_FILES}`. `Innodb_log_file_size` is the size in bytes of the each InnoDB redo log file in the log group. The combined size can be no more than 512 GB. Larger values mean less disk I/O due to less flushing checkpoint activity, but also slower recovery from a crash.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          tags:
            - tag: component
              value: system
        - uuid: 323775cd92a04a2a81aa0f6db16ea103
          name: 'Innodb number open files'
          type: DEPENDENT
          key: mysql.innodb_num_open_files
          value_type: FLOAT
          description: 'Number of open files held by InnoDB. InnoDB only.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_num_open_files'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: system
        - uuid: 75d8c835dd7340c2ba31063364a412df
          name: 'Innodb log written'
          type: DEPENDENT
          key: mysql.innodb_os_log_written
          value_type: FLOAT
          units: B
          description: 'Number of bytes written to the InnoDB log.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_os_log_written'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: system
        - uuid: 23e12a6eff4b4886b8003407c25c11dc
          name: 'InnoDB row lock time'
          type: DEPENDENT
          key: mysql.innodb_row_lock_time
          value_type: FLOAT
          units: s
          description: 'The total time spent in acquiring row locks for InnoDB tables, in milliseconds.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_row_lock_time'']/field[@name=''Value'']/text()'
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: 346c72cd57a24762bc9ed8fabba70bde
          name: 'InnoDB row lock time max'
          type: DEPENDENT
          key: mysql.innodb_row_lock_time_max
          value_type: FLOAT
          units: s
          description: 'The maximum time to acquire a row lock for InnoDB tables, in milliseconds.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_row_lock_time_max'']/field[@name=''Value'']/text()'
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: 6b7c9ed85e354d80b30ab34cef539be0
          name: 'InnoDB row lock waits'
          type: DEPENDENT
          key: mysql.innodb_row_lock_waits
          description: 'Number of times operations on InnoDB tables had to wait for a row lock.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Innodb_row_lock_waits'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: tables
        - uuid: fb60316605b34ad292e1a01b898aea36
          name: 'Max used connections'
          type: DEPENDENT
          key: mysql.max_used_connections
          description: 'The maximum number of connections that have been in use simultaneously since the server start.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Max_used_connections'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: connections
        - uuid: edb4e1bd71f74861a251d227a3338e69
          name: 'Open tables'
          type: DEPENDENT
          key: mysql.open_tables
          value_type: FLOAT
          description: 'Number of tables that are open.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Open_tables'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: tables
        - uuid: f6d9dae2b21043d18a498add8ca6de41
          name: 'Open table definitions'
          type: DEPENDENT
          key: mysql.open_table_definitions
          value_type: FLOAT
          description: 'Number of cached table definitions.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Open_table_definitions'']/field[@name=''Value'']/text()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: tables
        - uuid: ca43acd282a8435884b33af454b207fb
          name: Status
          type: ZABBIX_ACTIVE
          key: 'mysql.ping["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          description: 'MySQL server status.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return value.indexOf(''is alive'') !== -1 ? 1 : 0;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: fd1b0391ac694aa89950426d75ed3646
              expression: 'last(/MySQL by Zabbix agent active/mysql.ping["{$MYSQL.HOST}","{$MYSQL.PORT}"])=0'
              name: 'MySQL: Service is down'
              priority: HIGH
              description: 'MySQL is down.'
              tags:
                - tag: scope
                  value: availability
        - uuid: a11244940a734fba98f9845316493314
          name: 'Queries per second'
          type: DEPENDENT
          key: mysql.queries.rate
          value_type: FLOAT
          description: 'Number of statements executed by the server. This variable includes statements executed within stored programs, unlike the `Questions` variable.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Queries'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 790f6deb835a45d4af6e38c18566fccb
          name: 'Questions per second'
          type: DEPENDENT
          key: mysql.questions.rate
          value_type: FLOAT
          description: 'Number of statements executed by the server. This includes only statements sent to the server by clients and not statements executed within stored programs, unlike the `Queries` variable.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Questions'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: queries
        - uuid: bda290b8a1e940e7a98d23844f37670f
          name: 'Slow queries per second'
          type: DEPENDENT
          key: mysql.slow_queries.rate
          value_type: FLOAT
          description: 'Number of queries that have taken more than `long_query_time` seconds.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Slow_queries'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: queries
          triggers:
            - uuid: 72cbaa89dfc7447aad99ac7a9ae78a17
              expression: 'min(/MySQL by Zabbix agent active/mysql.slow_queries.rate,5m)>{$MYSQL.SLOW_QUERIES.MAX.WARN}'
              name: 'MySQL: Server has slow queries'
              event_name: 'MySQL: Server has slow queries (over {$MYSQL.SLOW_QUERIES.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'The number of slow queries is more than `{$MYSQL.SLOW_QUERIES.MAX.WARN}` in the last 5 minutes.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 358e381b2e014fd2b5746e08157af0e1
          name: 'Threads cached'
          type: DEPENDENT
          key: mysql.threads_cached
          description: 'Number of threads in the thread cache.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Threads_cached'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 242dbee07ddd4e16b7866aac62994f22
          name: 'Threads connected'
          type: DEPENDENT
          key: mysql.threads_connected
          description: 'Number of currently open connections.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Threads_connected'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: threads
        - uuid: d676416897564faa820e753e4e7a1c8c
          name: 'Threads created per second'
          type: DEPENDENT
          key: mysql.threads_created.rate
          value_type: FLOAT
          description: 'Number of threads created to handle connections. If the value of `Threads_created` is large, you may want to increase the `thread_cache_size` value. The cache miss rate can be calculated as `Threads_created`/`Connections`.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Threads_created'']/field[@name=''Value'']/text()'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: threads
        - uuid: be72a43bd41c4f56a1437df12b2ca67e
          name: 'Threads running'
          type: DEPENDENT
          key: mysql.threads_running
          description: 'Number of threads that are not sleeping.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Threads_running'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: threads
        - uuid: 20fc2471bcb44807b1ef7b4e4e3e8f4b
          name: Uptime
          type: DEPENDENT
          key: mysql.uptime
          units: uptime
          description: 'Number of seconds that the server has been up.'
          preprocessing:
            - type: XMLPATH
              parameters:
                - '/resultset/row[field/text()=''Uptime'']/field[@name=''Value'']/text()'
          master_item:
            key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 4e9e4b036c224c6a8f39a41e8ca2f225
              expression: 'nodata(/MySQL by Zabbix agent active/mysql.uptime,30m)=1'
              name: 'MySQL: Failed to fetch info data'
              event_name: 'MySQL: Failed to fetch info data (or no data for 30m)'
              priority: INFO
              description: 'Zabbix has not received any data for items for the last 30 minutes.'
              dependencies:
                - name: 'MySQL: Service is down'
                  expression: 'last(/MySQL by Zabbix agent active/mysql.ping["{$MYSQL.HOST}","{$MYSQL.PORT}"])=0'
              tags:
                - tag: scope
                  value: availability
            - uuid: 05c74a05d68445f38f4c5af591f0fbf8
              expression: 'last(/MySQL by Zabbix agent active/mysql.uptime)<10m'
              name: 'MySQL: Service has been restarted'
              event_name: 'MySQL: Service has been restarted (uptime < 10m)'
              priority: INFO
              description: 'MySQL uptime is less than 10 minutes.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 2071500ce5ac486fa322fbab8acac046
          name: Version
          type: ZABBIX_ACTIVE
          key: 'mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          delay: 15m
          value_type: CHAR
          description: 'MySQL server version.'
          preprocessing:
            - type: REGEX
              parameters:
                - '(Server version)\s+(.+)'
                - \2
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 87b33acf66644972b2a9c7daa4376634
              expression: 'last(/MySQL by Zabbix agent active/mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"],#1)<>last(/MySQL by Zabbix agent active/mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"],#2) and length(last(/MySQL by Zabbix agent active/mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"]))>0'
              name: 'MySQL: Version has changed'
              event_name: 'MySQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              description: 'The MySQL version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
      discovery_rules:
        - uuid: 5f6d9b9473494b6d8a9bd0f75211ffac
          name: 'Database discovery'
          type: ZABBIX_ACTIVE
          key: 'mysql.db.discovery["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          delay: 1h
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DBNAME}'
                value: '{$MYSQL.DBNAME.MATCHES}'
              - macro: '{#DBNAME}'
                value: '{$MYSQL.DBNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Scanning databases in DBMS.'
          item_prototypes:
            - uuid: def6d1e8f3584454b70fb11d99cb30d0
              name: 'Size of database {#DBNAME}'
              type: ZABBIX_ACTIVE
              key: 'mysql.dbsize["{$MYSQL.HOST}","{$MYSQL.PORT}","{#DBNAME}"]'
              delay: 5m
              units: B
              description: 'Database size.'
              preprocessing:
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  return JSON.stringify(value.split("\n").map(function (name) {
                  	return ({"{#DBNAME}": name});
                  }));
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
        - uuid: 5aa34129f8f144368e9cc8277ae3e66f
          name: 'MariaDB discovery'
          type: DEPENDENT
          key: mysql.extra_metric.discovery
          description: 'Used for additional metrics if MariaDB is used.'
          item_prototypes:
            - uuid: b869afe6691944879e1ba4b3f1277b5c
              name: 'Binlog commits'
              type: DEPENDENT
              key: 'mysql.binlog_commits[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of transactions committed to the binary log.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Binlog_commits'']/field[@name=''Value'']/text()'
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 8a0e3e5eee0a4f5a83bde012eeb3c150
              name: 'Binlog group commits'
              type: DEPENDENT
              key: 'mysql.binlog_group_commits[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of group commits done to the binary log.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Binlog_group_commits'']/field[@name=''Value'']/text()'
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 5252fc984cae4a75b4edc8895c8b1fc7
              name: 'Master GTID wait count'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_count[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The number of times `MASTER_GTID_WAIT` called.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Master_gtid_wait_count'']/field[@name=''Value'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 151fd5b8ac8e4ac7ac21eeb7b285156a
              name: 'Master GTID wait timeouts'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_timeouts[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of timeouts occurring in `MASTER_GTID_WAIT`.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Master_gtid_wait_timeouts'']/field[@name=''Value'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
              tags:
                - tag: component
                  value: transactions
            - uuid: 9fd7b98a3594423bb8c697003126eb93
              name: 'Master GTID wait time'
              type: DEPENDENT
              key: 'mysql.master_gtid_wait_time[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Total number of time spent in `MASTER_GTID_WAIT`.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Master_gtid_wait_time'']/field[@name=''Value'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
              tags:
                - tag: component
                  value: transactions
          master_item:
            key: 'mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return JSON.stringify(value.search(''MariaDB'')>-1 ? [{''{#SINGLETON}'': ''''}] : []);'
        - uuid: af8c7f2a0fe7405194887397ee722e47
          name: 'Replication discovery'
          type: ZABBIX_ACTIVE
          key: 'mysql.replication.discovery["{$MYSQL.HOST}","{$MYSQL.PORT}"]'
          delay: 1h
          description: 'If "show slave status" returns Master_Host, "Replication: *" items are created.'
          item_prototypes:
            - uuid: bdea1669775442779bfafd536b29c26b
              name: 'Replication Seconds Behind Master {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.seconds_behind_master["{#MASTER_HOST}"]'
              units: s
              description: |
                The number of seconds that the slave SQL thread is behind processing the master binary log.
                A high number (or an increasing one) can indicate that the slave is unable to handle events
                from the master in a timely fashion.
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row/field[@name=''Seconds_Behind_Master'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
                - type: NOT_MATCHES_REGEX
                  parameters:
                    - 'null'
                  error_handler: CUSTOM_ERROR
                  error_handler_params: 'Replication is not performed.'
              master_item:
                key: 'mysql.slave_status["{$MYSQL.HOST}","{$MYSQL.PORT}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: 31ac7f52dfc84a93a00862e40295419c
                  expression: 'min(/MySQL by Zabbix agent active/mysql.seconds_behind_master["{#MASTER_HOST}"],5m)>{$MYSQL.REPL_LAG.MAX.WARN}'
                  name: 'MySQL: Replication lag is too high'
                  event_name: 'MySQL: Replication lag is too high (over {$MYSQL.REPL_LAG.MAX.WARN} for 5m)'
                  priority: WARNING
                  description: 'Replication delay is too long.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: b024947e0071477c8ce14b3c6a0e4f66
              name: 'Replication Slave IO Running {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.slave_io_running["{#MASTER_HOST}"]'
              value_type: CHAR
              description: |
                Whether the I/O thread for reading the master's binary log is running.
                Normally, you want this to be Yes unless you have not yet started replication or have
                explicitly stopped it with STOP SLAVE.
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row/field[@name=''Slave_IO_Running'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.slave_status["{$MYSQL.HOST}","{$MYSQL.PORT}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: fceb91bcca89405faf5c68845d475d55
                  expression: 'count(/MySQL by Zabbix agent active/mysql.slave_io_running["{#MASTER_HOST}"],#1,"ne","Yes")=1'
                  name: 'MySQL: The slave I/O thread is not connected to a replication master'
                  priority: WARNING
                  description: 'Whether the slave I/O thread is connected to the master.'
                  dependencies:
                    - name: 'MySQL: The slave I/O thread is not running'
                      expression: 'count(/MySQL by Zabbix agent active/mysql.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  tags:
                    - tag: scope
                      value: availability
                - uuid: 7d4aa19570704ea5a571e73c19f57c73
                  expression: 'count(/MySQL by Zabbix agent active/mysql.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  name: 'MySQL: The slave I/O thread is not running'
                  priority: AVERAGE
                  description: 'Whether the I/O thread for reading the master''s binary log is running.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 3bf0331407f04af6b2c36892b34af135
              name: 'Replication Slave SQL Running {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.slave_sql_running["{#MASTER_HOST}"]'
              value_type: CHAR
              description: |
                Whether the SQL thread for executing events in the relay log is running.
                As with the I/O thread, this should normally be Yes.
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row/field[@name=''Slave_SQL_Running'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'mysql.slave_status["{$MYSQL.HOST}","{$MYSQL.PORT}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
              trigger_prototypes:
                - uuid: 01397ed577884506aec546fc8c6f1b08
                  expression: 'count(/MySQL by Zabbix agent active/mysql.slave_sql_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  name: 'MySQL: The SQL thread is not running'
                  priority: WARNING
                  description: 'Whether the SQL thread for executing events in the relay log is running.'
                  dependencies:
                    - name: 'MySQL: The slave I/O thread is not running'
                      expression: 'count(/MySQL by Zabbix agent active/mysql.slave_io_running["{#MASTER_HOST}"],#1,"eq","No")=1'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 9ac0db816bd7423d8956c05fb8e912d4
              name: 'Replication Slave SQL Running State {#MASTER_HOST}'
              type: DEPENDENT
              key: 'mysql.slave_sql_running_state["{#MASTER_HOST}"]'
              value_type: TEXT
              description: 'This shows the state of the SQL driver threads.'
              preprocessing:
                - type: XMLPATH
                  parameters:
                    - '/resultset/row[field/text()=''Slave_SQL_Running_State'']/field[@name=''Value'']/text()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 6h
              master_item:
                key: 'mysql.slave_status["{$MYSQL.HOST}","{$MYSQL.PORT}","{#MASTER_HOST}"]'
              tags:
                - tag: component
                  value: replication
            - uuid: 2a9a2449f0b945afb2b16a1f744ffaef
              name: 'Replication Slave status {#MASTER_HOST}'
              type: ZABBIX_ACTIVE
              key: 'mysql.slave_status["{$MYSQL.HOST}","{$MYSQL.PORT}","{#MASTER_HOST}"]'
              history: '0'
              value_type: TEXT
              description: 'The item gets status information on the essential parameters of the slave threads.'
              tags:
                - tag: component
                  value: raw
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var matches = value.match(/Master_Host.*>(.*)<.*/);
                  if (matches) {
                  	return JSON.stringify([{"{#MASTER_HOST}": matches[1]}]);
                  }
                  
                  return '[]';
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: mysql
      macros:
        - macro: '{$MYSQL.ABORTED_CONN.MAX.WARN}'
          value: '3'
          description: 'Number of failed attempts to connect to the MySQL server for trigger expressions.'
          config:
            type: TEXT
            priority: '3'
            section_name: Thresholds
            label: 'Number of failed attempts to connect threshold'
            description: 'Threshold for the maximum number of failed attempts to connect to the MySQL server. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.BUFF_UTIL.MIN.WARN}'
          value: '50'
          description: 'The minimum buffer pool utilization in percentage for trigger expressions.'
          config:
            type: TEXT
            priority: '6'
            section_name: Thresholds
            label: 'Buffer pool utilization threshold'
            description: 'Threshold of the minimum percentage of buffer pool utilization. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN}'
          value: '10'
          description: 'The maximum number of temporary tables created on a disk per second for trigger expressions.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Temporary tables created on a disk per second threshold'
            description: 'Threshold for the maximum number of temporary tables created on a disk per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_FILES.MAX.WARN}'
          value: '10'
          description: 'The maximum number of temporary files created on a disk per second for trigger expressions.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Temporary files created on a disk per second threshold'
            description: 'Threshold for the maximum number of temporary files created on a disk per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.CREATED_TMP_TABLES.MAX.WARN}'
          value: '30'
          description: 'The maximum number of temporary tables created in memory per second for trigger expressions.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Temporary tables created in memory per second threshold'
            description: 'Threshold for the maximum number of temporary tables created in memory per second. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.DBNAME.MATCHES}'
          value: .+
          description: 'Filter of discoverable databases.'
          config:
            type: TEXT
            priority: '11'
            section_name: Filters
            label: 'Include database filter'
            description: 'Regex string to include discovered database by its name.'
        - macro: '{$MYSQL.DBNAME.NOT_MATCHES}'
          value: information_schema
          description: 'Filter to exclude discovered databases.'
          config:
            type: TEXT
            priority: '12'
            section_name: Filters
            label: 'Exclude database filter'
            description: 'Regex string to exclude discovered database by its name.'
        - macro: '{$MYSQL.HOST}'
          value: 127.0.0.1
          description: 'Hostname or IP of MySQL host or container.'
          config:
            type: TEXT
            priority: '1'
            label: 'MySQL address'
            description: 'Hostname or IP address of MySQL host or container.'
        - macro: '{$MYSQL.INNODB_LOG_FILES}'
          value: '2'
          description: 'Number of physical files in the InnoDB redo log for calculating `innodb_log_file_size`.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'InnoDB redo log files number (for calculating)'
            description: 'Threshold for the maximum number of physical files in the InnoDB redo log for calculating `innodb_log_file_size`. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.PORT}'
          value: '3306'
          description: 'MySQL service port.'
          config:
            type: TEXT
            priority: '2'
            label: 'MySQL service port'
            description: 'In the range from 1 to 65535 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MYSQL.REPL_LAG.MAX.WARN}'
          value: 30m
          description: 'Amount of time the slave is behind the master for trigger expressions.'
          config:
            type: TEXT
            priority: '4'
            section_name: Thresholds
            label: 'Replication lag threshold'
            description: 'Threshold of the maximum time the slave is behind the master.'
        - macro: '{$MYSQL.SLOW_QUERIES.MAX.WARN}'
          value: '3'
          description: 'Number of slow queries for trigger expressions.'
          config:
            type: TEXT
            priority: '5'
            section_name: Thresholds
            label: 'Number of slow queries threshold'
            description: 'Threshold for the maximum number of slow queries. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
      dashboards:
        - uuid: 26e905c4d9334467b57de85a2916db87
          name: 'MySQL performance'
          pages:
            - widgets:
                - type: graph
                  name: 'MySQL: Operations'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent active'
                        name: 'MySQL: Operations'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'MySQL: Connections'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent active'
                        name: 'MySQL: Connections'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  name: 'MySQL: InnoDB buffer pool'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent active'
                        name: 'MySQL: InnoDB buffer pool'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graph
                  name: 'MySQL: Queries'
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent active'
                        name: 'MySQL: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: 'MySQL: Bandwidth'
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent active'
                        name: 'MySQL: Bandwidth'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  name: 'MySQL: Threads'
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'MySQL by Zabbix agent active'
                        name: 'MySQL: Threads'
                    - type: STRING
                      name: reference
                      value: AAAAF
      valuemaps:
        - uuid: 53bef1cc5ae849e4845ffdd0dd6bcc6a
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: 00ade9277d7c41e8b57d638b22d54372
      template: 'Oracle by ODBC'
      name: 'Oracle by ODBC'
      description: |
        1. Create an Oracle user for monitoring.
        
        2. Set the hostname or IP address of the Oracle DB instance, user name and password in host macros ({$ORACLE.HOST}, {$ORACLE.USER} and {$ORACLE.PASSWORD}).
          Do not forget to install the Microsoft ODBC driver on the Zabbix server or the Zabbix proxy.
          See Oracle documentation for instructions: https://www.oracle.com/database/technologies/releasenote-odbc-ic.html.
        
          Note! Credentials in the odbc.ini do not work for Oracle.
          Note! Be sure that ODBC connects to Oracle with session parameter NLS_NUMERIC_CHARACTERS= '.,' It is important for correct display float numbers in Zabbix.
        The "Service's TCP port state" item uses {$ORACLE.HOST} and {$ORACLE.PORT} macros to check the availability of the listener.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Overview
        
        The template is developed to monitor a single DBMS Oracle Database instance with ODBC and can monitor CDB or non-CDB installations.
        
        ## Supported versions
        
        Oracle Database 12c2 and newer.
        
        **Important! This integration queries the `V$ACTIVE_SESSION_HISTORY` dynamic performance view which is part of the Oracle Diagnostics Pack. Please make sure that you have the licence required for using this management pack.**
        
        ## Setup
        
        1. Create an Oracle Database user for monitoring:
        
            In CDB installations, it is possible to monitor tablespaces from the CDB (container database) and all PDBs (pluggable databases). To do so, a common user is needed with the correct rights:
        
            ```
            CREATE USER c##zabbix_mon IDENTIFIED BY <PASSWORD>;
            -- Grant access to the c##zabbix_mon user.
            ALTER USER c##zabbix_mon SET CONTAINER_DATA=ALL CONTAINER=CURRENT;
            GRANT CONNECT, CREATE SESSION TO c##zabbix_mon;
            GRANT SELECT_CATALOG_ROLE to c##zabbix_mon;
            GRANT SELECT ON v_$instance TO c##zabbix_mon;
            GRANT SELECT ON v_$database TO c##zabbix_mon;
            GRANT SELECT ON v_$sysmetric TO c##zabbix_mon;
            GRANT SELECT ON v_$system_parameter TO c##zabbix_mon;
            GRANT SELECT ON v_$session TO c##zabbix_mon;
            GRANT SELECT ON v_$recovery_file_dest TO c##zabbix_mon;
            GRANT SELECT ON v_$active_session_history TO c##zabbix_mon;
            GRANT SELECT ON v_$osstat TO c##zabbix_mon;
            GRANT SELECT ON v_$process TO c##zabbix_mon;
            GRANT SELECT ON v_$datafile TO c##zabbix_mon;
            GRANT SELECT ON v_$pgastat TO c##zabbix_mon;
            GRANT SELECT ON v_$sgastat TO c##zabbix_mon;
            GRANT SELECT ON v_$log TO c##zabbix_mon;
            GRANT SELECT ON v_$archive_dest TO c##zabbix_mon;
            GRANT SELECT ON v_$asm_diskgroup TO c##zabbix_mon;
            GRANT SELECT ON v_$asm_diskgroup_stat TO c##zabbix_mon;
            GRANT SELECT ON DBA_USERS TO c##zabbix_mon;
            ```
            This is needed because the template uses `CDB_*` views to monitor tablespaces from the CDB and different PDBs - the monitoring user therefore needs access to the container data objects on all PDBs.
        
            However, if you wish to monitor only a single PDB or a non-CDB instance, a local user is sufficient:
            
            ```
            CREATE USER zabbix_mon IDENTIFIED BY <PASSWORD>;
            -- Grant access to the zabbix_mon user.
            GRANT CONNECT, CREATE SESSION TO zabbix_mon;
            GRANT SELECT_CATALOG_ROLE to zabbix_mon;
            GRANT SELECT ON v_$instance TO zabbix_mon;
            GRANT SELECT ON v_$database TO zabbix_mon;
            GRANT SELECT ON v_$sysmetric TO zabbix_mon;
            GRANT SELECT ON v_$system_parameter TO zabbix_mon;
            GRANT SELECT ON v_$session TO zabbix_mon;
            GRANT SELECT ON v_$recovery_file_dest TO zabbix_mon;
            GRANT SELECT ON v_$active_session_history TO zabbix_mon;
            GRANT SELECT ON v_$osstat TO zabbix_mon;
            GRANT SELECT ON v_$process TO zabbix_mon;
            GRANT SELECT ON v_$datafile TO zabbix_mon;
            GRANT SELECT ON v_$pgastat TO zabbix_mon;
            GRANT SELECT ON v_$sgastat TO zabbix_mon;
            GRANT SELECT ON v_$log TO zabbix_mon;
            GRANT SELECT ON v_$archive_dest TO zabbix_mon;
            GRANT SELECT ON v_$asm_diskgroup TO zabbix_mon;
            GRANT SELECT ON v_$asm_diskgroup_stat TO zabbix_mon;
            GRANT SELECT ON DBA_USERS TO zabbix_mon;
            ```
            **Important! Ensure that the ODBC connection to Oracle includes the session parameter `NLS_NUMERIC_CHARACTERS= '.,'`. It is important for displaying the float numbers in Zabbix correctly.**
        
            **Important! These privileges grant the monitoring user `SELECT_CATALOG_ROLE`, which, in turn, gives access to thousands of tables in the database.**
            This role is required to access the `V$RESTORE_POINT` dynamic performance view.
            However, there are ways to go around this, if the `SELECT_CATALOG_ROLE` assigned to a monitoring user raises any security issues.
            One way to do this is using **pipelined table functions**:
        
              1. Log into your database as the `SYS` user or make sure that your administration user has the required privileges to execute the steps below;
        
              2. Create types for the table function:
        
                  ```sql
                  CREATE OR REPLACE TYPE zbx_mon_restore_point_row AS OBJECT (
                    SCN                           NUMBER,
                    DATABASE_INCARNATION#         NUMBER,
                    GUARANTEE_FLASHBACK_DATABASE  VARCHAR2(3),
                    STORAGE_SIZE                  NUMBER,
                    TIME                          TIMESTAMP(9),
                    RESTORE_POINT_TIME            TIMESTAMP(9),
                    PRESERVED                     VARCHAR2(3),
                    NAME                          VARCHAR2(128),
                    PDB_RESTORE_POINT             VARCHAR2(3),
                    CLEAN_PDB_RESTORE_POINT       VARCHAR2(3),
                    PDB_INCARNATION#              NUMBER,
                    REPLICATED                    VARCHAR2(3),
                    CON_ID                        NUMBER
                  );
                  CREATE OR REPLACE TYPE zbx_mon_restore_point_tab IS TABLE OF zbx_mon_restore_point_row;
                  ```
        
              3. Create the pipelined table function:
        
                  ```sql
                  CREATE OR REPLACE FUNCTION zbx_mon_restore_point RETURN zbx_mon_restore_point_tab PIPELINED AS
                  BEGIN
                    FOR i IN (SELECT * FROM V$RESTORE_POINT) LOOP
                      PIPE ROW (zbx_mon_restore_point_row(i.SCN, i.DATABASE_INCARNATION#, i.GUARANTEE_FLASHBACK_DATABASE, i.STORAGE_SIZE, i.TIME, i.RESTORE_POINT_TIME, i.PRESERVED, i.NAME, i.PDB_RESTORE_POINT, i.CLEAN_PDB_RESTORE_POINT, i.PDB_INCARNATION#, i.REPLICATED, i.CON_ID));
                    END LOOP;
                    RETURN;
                  END;
                  ```
        
              4. Grant the Zabbix monitoring user the Execute privilege on the created pipelined table function and replace the monitoring user `V$RESTORE_POINT` view with the `SYS` user function (in this example, the `SYS` user is used to create DB types and function):
        
                  ```sql
                  GRANT EXECUTE ON zbx_mon_restore_point TO c##zabbix_mon;
                  CREATE OR REPLACE VIEW c##zabbix_mon.V$RESTORE_POINT AS SELECT * FROM TABLE(SYS.zbx_mon_restore_point);
                  ```
        
              5. Finally, revoke the `SELECT_CATALOG_ROLE` and grant additional permissions that were previously covered by the `SELECT_CATALOG_ROLE`.
        
                  ```sql
                  REVOKE SELECT_CATALOG_ROLE FROM c##zabbix_mon;
                  GRANT SELECT ON v_$pdbs TO c##zabbix_mon;
                  GRANT SELECT ON v_$sort_segment TO c##zabbix_mon;
                  GRANT SELECT ON v_$parameter TO c##zabbix_mon;
                  GRANT SELECT ON CDB_TABLESPACES TO c##zabbix_mon;
                  GRANT SELECT ON CDB_DATA_FILES TO c##zabbix_mon;
                  GRANT SELECT ON CDB_FREE_SPACE TO c##zabbix_mon;
                  GRANT SELECT ON CDB_TEMP_FILES TO c##zabbix_mon;
                  ```
        
              > Note that in these examples, the monitoring user is named `c##zabbix_mon` and the system user - `SYS`. Change these example usernames to ones that are appropriate for your environment.
            
            If this workaround does not work for you, there are more options available, such as __materialized views__, but look out for data refresh as `V$RESTORE_POINT` is a dynamic performance view.
        
        2. Install the ODBC driver on Zabbix server or Zabbix proxy.
          See the [Oracle documentation](https://www.oracle.com/database/technologies/releasenote-odbc-ic.html) for instructions.
        
        3. Configure Zabbix server or Zabbix proxy for using the Oracle environment:
        
            This step is required only when:
            
            * installing Oracle Instant Client with .rpm packages with a version < 19.3 (if Instant Client is the only Oracle software installed on Zabbix server or Zabbix proxy);
            
            * installing Oracle Instant Client manually with .zip files.
          
            There are multiple configuration options:
            
              1. Using the `LDCONFIG` utility **(recommended option)**:
          
                  To update the runtime link path, it is recommended to use the ```LDCONFIG``` utility, for example:
            
                  ```
                  # sh -c "echo /opt/oracle/instantclient_19_18 > /etc/ld.so.conf.d/oracle-instantclient.conf"
                  # ldconfig
                  ```
          
              2. Using the application configuration file:
          
                  An alternative solution is to export the required variables by editing or adding a new application configuration file:
            
                   * ```/etc/sysconfig/zabbix-server # for server```
            
                   * ```/etc/sysconfig/zabbix-proxy # for proxy```
            
                  And then, adding:
                
                  ```
                  # Oracle Instant Client library
                  LD_LIBRARY_PATH=/opt/oracle/instantclient_19_18:$LD_LIBRARY_PATH
                  export LD_LIBRARY_PATH
                  ```
            
            Keep in mind that the library paths will vary depending on your installation.
        
            This is a minimal configuration example. Depending on the Oracle Instant Client version, required functionality and host operating system, a different set of additional packages might need to be installed.
            For more detailed configuration instructions, see the [official Oracle Instant Client installation instructions for Linux](https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html).
        
        4. Restart Zabbix server or Zabbix proxy.
        
        5. Set the username and password in host wizard configuration fields `Username` and `Password`.
        
        6. Set the `Oracle URL`, `Oracle driver path` and `Oracle Service Name` in host wizard configuration fields.
        
            * `Oracle URL` is a hostname or IP address of the Oracle DB instance.
        
            * `Oracle driver path` is a path to the driver location in the OS. The ODBC driver file should be found in the Instant Client directory and named `libsqora.so.XX.Y`.
        
            * `Oracle Service Name` is a service name to which the host will connect to. It is important as it determines if the connection is established to a non-CDB, CDB, or PDB. If you wish to monitor tablespaces of all PDBs, you will need to set a service name that points to the CDB.
              Active service names can be seen from the instance running Oracle Database with `lsnrctl status`.
              
            **Important! Make sure that the user created in step #1 is present on the specified service.**
        
            The "Service's TCP port state" item uses `{$ORACLE.HOST}` and `{$ORACLE.PORT}` macros to check the availability of the listener.
      vendor:
        name: Zabbix
        version: 7.4-1
      groups:
        - name: Templates/Databases
      items:
        - uuid: 76591a03cf684d30ae15eca8519ce1dd
          name: 'Get archive log'
          type: ODBC
          key: 'db.odbc.get[get_archivelog,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          delay: 1h
          history: '0'
          value_type: TEXT
          params: |
            SELECT d.dest_name
            FROM v$archive_dest d , v$database db WHERE d.status != 'INACTIVE' AND db.log_mode = 'ARCHIVELOG';
          username: '{$ORACLE.USER}'
          password: '{$ORACLE.PASSWORD}'
          description: 'Gets the destinations of the log archive.'
          tags:
            - tag: component
              value: raw
        - uuid: 10f3da9afb674ff18956aa99229de8dd
          name: 'Get ASM disk groups'
          type: ODBC
          key: 'db.odbc.get[get_asm,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          delay: 1h
          history: '0'
          value_type: TEXT
          params: 'SELECT name AS dgname FROM v$asm_diskgroup;'
          username: '{$ORACLE.USER}'
          password: '{$ORACLE.PASSWORD}'
          description: 'Gets the ASM disk groups.'
          tags:
            - tag: component
              value: raw
        - uuid: 7ca479f46bb2435f9f9cb62d404fa37c
          name: 'Get database'
          type: ODBC
          key: 'db.odbc.get[get_db,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          delay: 1h
          history: '0'
          value_type: TEXT
          params: 'SELECT name as DBNAME, DECODE(CDB, ''YES'', ''CDB'', ''No-CDB'') AS TYPE  FROM V$DATABASE;'
          username: '{$ORACLE.USER}'
          password: '{$ORACLE.PASSWORD}'
          description: 'Gets the databases in the database management system (DBMS).'
          tags:
            - tag: component
              value: raw
        - uuid: dde19b79507648bd80a82a0575bf8671
          name: 'Get instance state'
          type: ODBC
          key: 'db.odbc.get[get_instance_state,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT
            INSTANCE_NAME,
            HOST_NAME,
            VERSION || '-' || EDITION AS VERSION,
            floor((SYSDATE - startup_time)*60*60*24) AS UPTIME,
            decode(status,'STARTED',1,'MOUNTED',2,'OPEN',3,'OPEN MIGRATE',4, 0) AS STATUS,
            decode(archiver,'STOPPED',1,'STARTED',2,'FAILED',3, 0) AS  ARCHIVER,
            decode(instance_role,'PRIMARY_INSTANCE',1,'SECONDARY_INSTANCE',2, 0) AS  INSTANCE_ROLE
            FROM v$instance;
          username: '{$ORACLE.USER}'
          password: '{$ORACLE.PASSWORD}'
          description: 'Gets the state of the current instance.'
          tags:
            - tag: component
              value: raw
        - uuid: de5aa291b7da4733ad26d517e8ff55cf
          name: 'Get PDB'
          type: ODBC
          key: 'db.odbc.get[get_pdb,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          delay: 1h
          history: '0'
          value_type: TEXT
          params: 'SELECT CON_ID, name as DBNAME FROM V$PDBS;'
          username: '{$ORACLE.USER}'
          password: '{$ORACLE.PASSWORD}'
          description: 'Gets the pluggable database (PDB) in DBMS.'
          tags:
            - tag: component
              value: raw
        - uuid: 3839683749974cdeafd9178bdccb38d6
          name: 'Get system metrics'
          type: ODBC
          key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          delay: 0;m0-59
          history: '0'
          value_type: TEXT
          params: |
            SELECT 'SYS::' || METRIC_NAME AS METRIC, ROUND(VALUE,3) as VALUE
             FROM V$SYSMETRIC WHERE GROUP_ID = 2
            UNION
              SELECT 'SYSPARAM::' || INITCAP(NAME) AS METRIC, to_number(VALUE)
              FROM V$SYSTEM_PARAMETER WHERE NAME IN ('sessions', 'processes', 'db_files')
            UNION
             SELECT 'SESSION::Long time locked' ,count(*) FROM V$SESSION s WHERE s.BLOCKING_SESSION IS NOT NULL AND s.BLOCKING_SESSION_STATUS='VALID' AND s.SECONDS_IN_WAIT > {$ORACLE.SESSION.LOCK.MAX.TIME}
            UNION
            SELECT 'SESSION::Lock rate' ,(cnt_block / cnt_all)* 100 pct
            FROM ( SELECT COUNT(*) cnt_block FROM v$session WHERE blocking_session IS NOT NULL), ( SELECT COUNT(*) cnt_all FROM v$session)
            UNION
              SELECT 'SESSION::Long time locked' ,count(*) FROM V$SESSION s WHERE s.BLOCKING_SESSION IS NOT NULL AND s.BLOCKING_SESSION_STATUS='VALID' AND s.SECONDS_IN_WAIT > {$ORACLE.SESSION.LOCK.MAX.TIME}
            UNION
             SELECT 'SESSION::Total', COUNT(*) AS VALUE FROM V$SESSION
            UNION
            SELECT 'SESSION::Concurrency rate', NVL(ROUND(SUM(duty_act.cnt*100 / num_cores.val)), 0)
            FROM
            ( SELECT DECODE(session_state, 'ON CPU', 'CPU', wait_class) wait_class, ROUND(COUNT(*)/(60 * 15), 1) cnt
            FROM v$active_session_history sh
            WHERE sh.sample_time >= SYSDATE - 15 / 1440 AND DECODE(session_state, 'ON CPU', 'CPU', wait_class) IN('Concurrency')
            GROUP BY DECODE(session_state, 'ON CPU', 'CPU', wait_class)) duty_act,
            ( SELECT SUM(value) val FROM v$osstat WHERE stat_name = 'NUM_CPU_CORES') num_cores
            UNION
             SELECT 'PGA::' || INITCAP(NAME), VALUE FROM V$PGASTAT
            UNION
             SELECT 'FRA::Space Limit' AS METRIC, space_limit AS VALUE FROM V$RECOVERY_FILE_DEST
            UNION
             SELECT 'FRA::Space Used', space_used AS VALUE FROM V$RECOVERY_FILE_DEST
            UNION
             SELECT 'FRA::Space Reclaimable', space_reclaimable AS VALUE FROM V$RECOVERY_FILE_DEST
            UNION
             SELECT 'FRA::Number Of Files', number_of_files AS VALUE FROM V$RECOVERY_FILE_DEST
            UNION
             SELECT 'FRA::Usable Pct', DECODE(space_limit, 0, 0,(100-(100 *(space_used-space_reclaimable)/ space_limit))) AS VALUE FROM V$RECOVERY_FILE_DEST
            UNION
             SELECT 'FRA::Restore Point', COUNT(*) AS VALUE FROM V$RESTORE_POINT
            UNION
             SELECT 'PROC::Procnum', COUNT(*) FROM v$process
            UNION
             SELECT 'DATAFILE::Count', COUNT(*) FROM v$datafile
            UNION
             SELECT 'SGA::' || INITCAP(pool), SUM(bytes) FROM V$SGASTAT
             WHERE pool IN ( 'java pool', 'large pool' ) GROUP BY pool
            UNION
             SELECT 'SGA::Shared Pool', SUM(bytes) FROM V$SGASTAT
             WHERE pool = 'shared pool' AND name NOT IN ('library cache', 'dictionary cache', 'free memory', 'sql area')
            UNION
             SELECT 'SGA::' || INITCAP(name), bytes FROM V$SGASTAT
             WHERE pool IS NULL AND name IN ('log_buffer', 'fixed_sga')
            UNION
             SELECT 'SGA::Buffer_Cache', SUM(bytes) FROM V$SGASTAT
             WHERE pool IS NULL AND name IN ('buffer_cache', 'db_block_buffers')
            UNION
             SELECT 'REDO::Available', count(*) from v$log t where t.status in ('INACTIVE', 'UNUSED')
            UNION
             SELECT 'USER::Expire password', ROUND(DECODE(SIGN(NVL(u.expiry_date, SYSDATE + 999) - SYSDATE),-1, 0, NVL(u.expiry_date, SYSDATE + 999) - SYSDATE)) exp_passwd_days_before
            FROM dba_users u WHERE username = UPPER('{$ORACLE.USER}');
          username: '{$ORACLE.USER}'
          password: '{$ORACLE.PASSWORD}'
          description: 'Gets the values of the system metrics.'
          tags:
            - tag: component
              value: raw
        - uuid: 2310462a8936465c8a62d8586ab0ba65
          name: 'Get tablespace'
          type: ODBC
          key: 'db.odbc.get[get_tablespace,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          delay: 1h
          history: '0'
          value_type: TEXT
          params: |
            SELECT
            	CON_ID,
            	NVL(CON$NAME, 'DB') CON_NAME,
            	TABLESPACE_NAME TABLESPACE,
            	CONTENTS
            FROM
            	CDB_TABLESPACES;
          username: '{$ORACLE.USER}'
          password: '{$ORACLE.PASSWORD}'
          description: 'Gets tablespaces in DBMS.'
          tags:
            - tag: component
              value: raw
        - uuid: 7ee99dfbd8dd4048bc2867aaa2fc335e
          name: 'Service''s TCP port state'
          key: 'net.tcp.service[tcp,{$ORACLE.HOST},{$ORACLE.PORT}]'
          delay: 30s
          description: 'Checks the availability of Oracle on the TCP port.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: health
            - tag: component
              value: network
        - uuid: 6b6ce717919e45df93015a8f65337055
          name: 'Active parallel sessions'
          type: DEPENDENT
          key: oracle.active_parallel_sessions
          value_type: FLOAT
          description: 'The number of active parallel sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Active Parallel Sessions'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: sessions
        - uuid: 928b095ffe57404eb6863b06b466524d
          name: 'Active serial sessions'
          type: DEPENDENT
          key: oracle.active_serial_sessions
          value_type: FLOAT
          description: 'The number of active serial sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Active Serial Sessions'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: sessions
        - uuid: 70633c6c4e27410dabcf035dd583f820
          name: 'Average active sessions'
          type: DEPENDENT
          key: oracle.active_sessions
          value_type: FLOAT
          description: 'The average number of active sessions at a point in time that are either working or waiting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Average Active Sessions'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: sessions
        - uuid: eb9f4179a87249fc9df9989f58502a12
          name: 'Archiver state'
          type: DEPENDENT
          key: oracle.archiver_state
          description: 'The status of automatic archiving.'
          valuemap:
            name: 'Oracle archiver state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..ARCHIVER.first()
          master_item:
            key: 'db.odbc.get[get_instance_state,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: 836e01f5247a468dbf1866a744979376
          name: 'Buffer cache hit ratio'
          type: DEPENDENT
          key: oracle.buffer_cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: 'The ratio of buffer cache hits ((LogRead - PhyRead)/LogRead).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Buffer Cache Hit Ratio'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: cache
        - uuid: dedafce88267427a8f0b51d74de28c58
          name: 'Global cache blocks corrupted'
          type: DEPENDENT
          key: oracle.cache_blocks_corrupt
          units: Rps
          description: 'The number of blocks that encountered corruption or checksum failure during the interconnect.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Global Cache Blocks Corrupted'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: cache
        - uuid: d0d0dbbf1869487d957e60d03e8e3512
          name: 'Global cache blocks lost'
          type: DEPENDENT
          key: oracle.cache_blocks_lost
          units: Rps
          description: 'The number of lost global cache blocks.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Global Cache Blocks Lost'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: cache
        - uuid: 50ea6f52e01c44e5b9039add026faaa2
          name: 'Cursor cache hit ratio'
          type: DEPENDENT
          key: oracle.cursor_cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: 'The ratio of cursor cache hits (CursorCacheHit/SoftParse).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Cursor Cache Hit Ratio'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: cache
        - uuid: 82228fbb70bf4660aa64bdde2f57686d
          name: 'Database CPU time ratio'
          type: DEPENDENT
          key: oracle.database_cpu_time_ratio
          value_type: FLOAT
          units: '%'
          description: 'The ratio calculated by dividing the total CPU (used by the database) by the Oracle time model statistic DB time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Database CPU Time Ratio'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: cpu
        - uuid: 877272b0b9424d279b1efaa6536eb19b
          name: 'Database wait time ratio'
          type: DEPENDENT
          key: oracle.database_wait_time_ratio
          value_type: FLOAT
          units: '%'
          description: 'Wait time - the time that the server process spends waiting for available shared resources to be released by other server processes such as latches, locks, data buffers, etc.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Database Wait Time Ratio'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: 751fe010337e40a5a12fc24d327ffcee
          name: 'Datafiles count'
          type: DEPENDENT
          key: oracle.db_files_count
          description: 'The current number of datafiles.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''DATAFILE::Count'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: datafiles
        - uuid: a0e263bf207042058b5d9d2e735e05eb
          name: 'Datafiles limit'
          type: DEPENDENT
          key: oracle.db_files_limit
          description: 'The maximum allowable number of datafiles.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYSPARAM::Db_Files'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: datafiles
        - uuid: 22d9cccf44924f99aaf444c80b3beab9
          name: 'Disk sort per second'
          type: DEPENDENT
          key: oracle.disk_sorts
          value_type: FLOAT
          units: Rps
          description: 'The number of sorts going to disk per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Disk Sort Per Sec'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: 46e0598b703a412e96a3b18e2248e754
          name: 'Enqueue timeouts per second'
          type: DEPENDENT
          key: oracle.enqueue_timeouts_rate
          value_type: FLOAT
          units: Rps
          description: 'Enqueue timeouts per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Enqueue Timeouts Per Sec'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: beca246cadb44e48a20bc8809624a6f4
          name: 'FRA, Number of files'
          type: DEPENDENT
          key: oracle.fra_number_of_files
          description: 'The number of files in the FRA.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''FRA::Number Of Files'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: fra
        - uuid: 61eb041ea3b349df88cb3495b383fbe4
          name: 'FRA, Number of restore points'
          type: DEPENDENT
          key: oracle.fra_restore_point
          value_type: FLOAT
          description: 'Number of restore points in the FRA.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''FRA::Restore Point'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: fra
        - uuid: 375e094a1a024a19b8e69e4f362c0163
          name: 'FRA, Space limit'
          type: DEPENDENT
          key: oracle.fra_space_limit
          units: B
          description: 'The maximum amount of disk space (in bytes) that the database can use for the Fast Recovery Area (FRA).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''FRA::Space Limit'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: fra
        - uuid: 4028e389cc9e4b24946657f1ded1ba47
          name: 'FRA, Space reclaimable'
          type: DEPENDENT
          key: oracle.fra_space_reclaimable
          units: B
          description: 'The total amount of disk space (in bytes) that can be created by deleting obsolete, redundant, and other low-priority files from the FRA.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''FRA::Space Reclaimable'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: fra
        - uuid: 40b03e917c3c4c0385536336e48affcb
          name: 'FRA, Used space'
          type: DEPENDENT
          key: oracle.fra_space_used
          units: B
          description: 'The amount of disk space (in bytes) used by FRA files created in the current and all the previous FRAs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''FRA::Space Used'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: fra
        - uuid: b29c93eecf9d4d1b8c5de1ce9721801f
          name: 'FRA, Usable space in %'
          type: DEPENDENT
          key: oracle.fra_usable_pct
          value_type: FLOAT
          units: '%'
          description: 'Percentage of space usable in the FRA.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''FRA::Usable Pct'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: fra
        - uuid: 3243beb0fe70425f8d71938a52f765ae
          name: 'GC CR block received per second'
          type: DEPENDENT
          key: oracle.gc_cr_block_received_rate
          value_type: FLOAT
          units: Rps
          description: 'The global cache (GC) and the consistent read (CR) block received per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::GC CR Block Received Per Second'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: cache
        - uuid: cc3c9200deed42e5a8e187e82c123009
          name: 'Instance role'
          type: DEPENDENT
          key: oracle.instance.role
          description: 'Indicates whether the instance is an active instance or an inactive secondary instance.'
          valuemap:
            name: 'Oracle instance role'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..INSTANCE_ROLE.first()
          master_item:
            key: 'db.odbc.get[get_instance_state,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: 3da27d558e034236a42b3b94bfa13159
          name: 'Instance hostname'
          type: DEPENDENT
          key: oracle.instance_hostname
          value_type: CHAR
          description: 'The name of the host machine.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..HOST_NAME.first()
          master_item:
            key: 'db.odbc.get[get_instance_state,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 618a3e3c82dc4ccba82477afdd100a98
              expression: 'last(/Oracle by ODBC/oracle.instance_hostname,#1)<>last(/Oracle by ODBC/oracle.instance_hostname,#2) and length(last(/Oracle by ODBC/oracle.instance_hostname))>0'
              name: 'Oracle: Instance hostname has changed'
              event_name: 'Oracle: Instance hostname has changed (new hostname received: {ITEM.VALUE})'
              priority: INFO
              description: 'An Oracle Database instance hostname has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 4e5df3339a2940c6b3cdad6f5b65234b
          name: 'Instance name'
          type: DEPENDENT
          key: oracle.instance_name
          value_type: CHAR
          description: 'The name of the instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..INSTANCE_NAME.first()
          master_item:
            key: 'db.odbc.get[get_instance_state,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 2fe53d1d931e4eb38fef10a3171c1665
              expression: 'last(/Oracle by ODBC/oracle.instance_name,#1)<>last(/Oracle by ODBC/oracle.instance_name,#2) and length(last(/Oracle by ODBC/oracle.instance_name))>0'
              name: 'Oracle: Instance name has changed'
              event_name: 'Oracle: Instance name has changed (new name received: {ITEM.VALUE})'
              priority: INFO
              description: 'An Oracle Database instance name has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 632a953eead74114bdaf640bbf5929a5
          name: 'Instance status'
          type: DEPENDENT
          key: oracle.instance_status
          description: 'The status of the instance.'
          valuemap:
            name: 'Oracle instance status'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..STATUS.first()
          master_item:
            key: 'db.odbc.get[get_instance_state,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: 9a3084287a354fb0b0eb5de377a6de92
          name: 'Library cache hit ratio'
          type: DEPENDENT
          key: oracle.library_cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: 'The ratio of library cache hits (Hits/Pins).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Library Cache Hit Ratio'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: cache
        - uuid: ac44884b2518485eae4bc7caf46799a8
          name: 'Logons per second'
          type: DEPENDENT
          key: oracle.logons_rate
          value_type: FLOAT
          units: Rps
          description: 'The number of logon attempts.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Logons Per Sec'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: f7691a5d7ef74a4d99cac61835052fba
          name: 'Long table scans per second'
          type: DEPENDENT
          key: oracle.long_table_scans_rate
          value_type: FLOAT
          units: Rps
          description: 'The number of long table scans per second. A table is considered long if it is not cached and if its high water mark is greater than five blocks.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Long Table Scans Per Sec'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: 49445baea18640ea844f869c51aee565
          name: 'Memory sorts ratio'
          type: DEPENDENT
          key: oracle.memory_sorts_ratio
          value_type: FLOAT
          units: '%'
          description: 'The percentage of sorts (from `ORDER BY` clauses or index building) that are done to disk vs. in-memory.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Memory Sorts Ratio'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: 786188c7719048cb863450f98ab921ac
          name: 'PGA, Global memory bound'
          type: DEPENDENT
          key: oracle.pga_global_bound
          units: B
          description: 'The maximum size of a work area executed in automatic mode.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''PGA::Global Memory Bound'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: pga
        - uuid: 1f532b6599f34db285b60a8879638d75
          name: 'PGA, Aggregate target parameter'
          type: DEPENDENT
          key: oracle.pga_target
          units: B
          description: 'The current value of the `PGA_AGGREGATE_TARGET` initialization parameter. If this parameter is not set, then its value is "0" and automatic management of the PGA memory is disabled.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''PGA::Aggregate Pga Target Parameter'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: pga
        - uuid: 001bf0d526cb455386f5a63e6bb8f410
          name: 'Physical reads per second'
          type: DEPENDENT
          key: oracle.physical_reads_rate
          value_type: FLOAT
          units: Rps
          description: 'Reads per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Physical Reads Per Sec'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: disk
        - uuid: 2f305e09eafd4f7a9360f138be20a631
          name: 'Physical reads bytes per second'
          type: DEPENDENT
          key: oracle.physical_read_bytes_rate
          value_type: FLOAT
          units: Bps
          description: 'Read bytes per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Physical Read Bytes Per Sec'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: disk
        - uuid: d20f81d99e6647479abcc9ffcbc208fc
          name: 'Physical writes per second'
          type: DEPENDENT
          key: oracle.physical_writes_rate
          value_type: FLOAT
          units: Rps
          description: 'Writes per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Physical Writes Per Sec'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: disk
        - uuid: e2e21384fbae431a88f1eef610b0307b
          name: 'Physical writes bytes per second'
          type: DEPENDENT
          key: oracle.physical_write_bytes_rate
          value_type: FLOAT
          units: Bps
          description: 'Write bytes per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Physical Write Bytes Per Sec'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: disk
        - uuid: 533ae91bb94e4077870aa362a8cea7e5
          name: 'Number of processes'
          type: DEPENDENT
          key: oracle.processes_count
          description: 'The current number of user processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''PROC::Procnum'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: system
        - uuid: 721c04b5f3ba42d0ae7acceb5876c360
          name: 'Processes limit'
          type: DEPENDENT
          key: oracle.processes_limit
          description: 'The maximum number of user processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYSPARAM::Processes'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: system
        - uuid: 65064008eef54657b7b7f2beeba70b0a
          name: 'Redo logs available to switch'
          type: DEPENDENT
          key: oracle.redo_logs_available
          description: 'The number of inactive/unused redo logs available for log switching.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''REDO::Available'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 1348b1e854e64d34b6b00be118f045c3
              expression: 'max(/Oracle by ODBC/oracle.redo_logs_available,5m) < {$ORACLE.REDO.MIN.WARN}'
              name: 'Oracle: Number of REDO logs available for switching is too low'
              event_name: 'Oracle: Number of REDO logs available for switching is too low (less {$ORACLE.REDO.MIN.WARN} for 5 min)'
              priority: WARNING
              description: 'The number of inactive/unused redos available for log switching is low (risk of database downtime).'
              tags:
                - tag: scope
                  value: capacity
        - uuid: ab298981f26a4ec6849e1155ce35ee76
          name: 'Rows per sort'
          type: DEPENDENT
          key: oracle.rows_per_sort
          value_type: FLOAT
          description: 'The average number of rows per sort for all types of sorts performed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Rows Per Sort'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: ddbdd3d7d40d42b9b9711470516a5aec
          name: 'SQL service response time'
          type: DEPENDENT
          key: oracle.service_response_time
          value_type: FLOAT
          units: s
          description: 'The Structured Query Language (SQL) service response time expressed in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::SQL Service Response Time'')].VALUE.first()'
            - type: MULTIPLIER
              parameters:
                - '0.01'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: e269a27f3c3f47ae86fef231da2a6fce
          name: 'Active background sessions'
          type: DEPENDENT
          key: oracle.session_active_background
          value_type: FLOAT
          description: 'The number of active background sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SESSION::Active Background'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: sessions
        - uuid: 6e8defc1e3e2485784d8bef6e2b988c7
          name: 'Active user sessions'
          type: DEPENDENT
          key: oracle.session_active_user
          value_type: FLOAT
          description: 'The number of active user sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SESSION::Active User'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: sessions
        - uuid: a3f2b314a6354d238d6604afa2333ae6
          name: 'Sessions concurrency'
          type: DEPENDENT
          key: oracle.session_concurrency_rate
          value_type: FLOAT
          units: '%'
          description: 'The percentage of concurrency. Concurrency is a database behavior when different transactions request to change the same resource. In the case of modifying data transactions, it sequentially temporarily blocks the right to change the data, and the rest of the transactions wait for access. When the access to a resource is locked for a long time, the concurrency grows (like the transaction queue), often leaving an extremely negative impact on performance. A high contention value does not indicate the root cause of the problem, but is a signal to search for it.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SESSION::Concurrency rate'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: sessions
          triggers:
            - uuid: 7099e4a160c1446395b9e5b721db7b38
              expression: 'min(/Oracle by ODBC/oracle.session_concurrency_rate,5m) > {$ORACLE.CONCURRENCY.MAX.WARN}'
              name: 'Oracle: Too high database concurrency'
              event_name: 'Oracle: Too high database concurrency (over {$ORACLE.CONCURRENCY.MAX.WARN}% for 5 min)'
              priority: WARNING
              description: 'The concurrency rate exceeds `{$ORACLE.CONCURRENCY.MAX.WARN}`%. A high contention value does not indicate the root cause of the problem, but is a signal to review resource consumption (determine the "heaviest" queries in the database, trace sessions, etc.) This will help find the root cause and possible optimization points both in database configuration and the logic of building queries.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 3459ae7c82454882a9655db8a83120fd
          name: 'Session count'
          type: DEPENDENT
          key: oracle.session_count
          value_type: FLOAT
          description: 'The session count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SESSION::Total'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: sessions
        - uuid: 5abf01d0bad442e7817752ae01dfc2d2
          name: 'Inactive user sessions'
          type: DEPENDENT
          key: oracle.session_inactive_user
          value_type: FLOAT
          description: 'The number of inactive user sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SESSION::Inactive User'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: sessions
        - uuid: ebc142a0784041d2bbe982c4d766b98f
          name: 'Sessions limit'
          type: DEPENDENT
          key: oracle.session_limit
          description: 'The user and system sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYSPARAM::Sessions'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: sessions
        - uuid: 64361f8862e8482d86a8bdd71c709142
          name: 'Sessions lock rate'
          type: DEPENDENT
          key: oracle.session_lock_rate
          value_type: FLOAT
          units: '%'
          description: 'The percentage of locked sessions. Locks are mechanisms that prevent destructive interaction between transactions accessing the same resource - either user objects, such as tables and rows or system objects not visible to users, such as shared data structures in memory and data dictionary rows.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SESSION::Lock rate'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: sessions
          triggers:
            - uuid: 9a75f3a039094ca89c2ba7e3fa93b1a8
              expression: 'min(/Oracle by ODBC/oracle.session_lock_rate,5m) > {$ORACLE.SESSIONS.LOCK.MAX.WARN}'
              name: 'Oracle: Too many locked sessions'
              event_name: 'Oracle: Too many locked sessions (over {$ORACLE.SESSIONS.LOCK.MAX.WARN}% for 5 min)'
              priority: WARNING
              description: 'The number of locked sessions exceeds `{$ORACLE.SESSIONS.LOCK.MAX.WARN}`% of the running sessions.'
              tags:
                - tag: scope
                  value: performance
        - uuid: a9669cb6290b4a158e7f02c1f079b6f9
          name: 'Sessions locked over {$ORACLE.SESSION.LOCK.MAX.TIME}s'
          type: DEPENDENT
          key: oracle.session_long_time_locked
          value_type: FLOAT
          description: 'The count of the prolongedly locked sessions. (You can change the duration of the maximum session lock in seconds for a query using the `{$ORACLE.SESSION.LOCK.MAX.TIME}` macro. Default = 600 s).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SESSION::Long time locked'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: sessions
          triggers:
            - uuid: a8f5ec966f5e4c72baad1380eda4d0a2
              expression: 'min(/Oracle by ODBC/oracle.session_long_time_locked,5m) > {$ORACLE.SESSION.LONG.LOCK.MAX.WARN}'
              name: 'Oracle: Too many sessions locked'
              event_name: 'Oracle: Too many sessions locked over {$ORACLE.SESSION.LOCK.MAX.TIME}s (over {$ORACLE.SESSION.LONG.LOCK.MAX.WARN} for 5 min)'
              priority: WARNING
              description: 'The number of locked sessions exceeding `{$ORACLE.SESSION.LOCK.MAX.TIME}` seconds is too high. Long-term locks can negatively affect the database performance. Therefore, if they are detected, you should first find the most difficult queries from the database point of view and then analyze possible resource leaks.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 94fe3a129f08415bb7e02a862bd9e8a8
          name: 'SGA, buffer cache'
          type: DEPENDENT
          key: oracle.sga_buffer_cache
          units: B
          description: 'The size of standard block cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SGA::Buffer_Cache'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: cache
            - tag: component
              value: sga
        - uuid: 062fbd601d6f41208e364c80f1d08b1e
          name: 'SGA, fixed'
          type: DEPENDENT
          key: oracle.sga_fixed
          units: B
          description: 'The fixed System Global Area (SGA) is an internal housekeeping area.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SGA::Fixed_Sga'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: sga
        - uuid: 614066ff91e144dbae58b4920c1db932
          name: 'SGA, java pool'
          type: DEPENDENT
          key: oracle.sga_java_pool
          units: B
          description: 'The memory is allocated from the Java pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SGA::Java Pool'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: sga
        - uuid: 0f726310d4a8426188658f7c093c3989
          name: 'SGA, large pool'
          type: DEPENDENT
          key: oracle.sga_large_pool
          units: B
          description: 'The memory is allocated from a large pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SGA::Large Pool'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: sga
        - uuid: 03e9cea3887447349c9116b89b1be026
          name: 'SGA, log buffer'
          type: DEPENDENT
          key: oracle.sga_log_buffer
          units: B
          description: 'The number of bytes allocated for the redo log buffer.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SGA::Log_Buffer'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: sga
        - uuid: eb4c2f63ef8449d99794e5fdb7fed7bf
          name: 'SGA, shared pool'
          type: DEPENDENT
          key: oracle.sga_shared_pool
          units: B
          description: 'The memory is allocated from a shared pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SGA::Shared Pool'')].VALUE.first()'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: sga
        - uuid: b14b0126cf64436ea206ec151984cd95
          name: 'Shared pool free %'
          type: DEPENDENT
          key: oracle.shared_pool_free
          value_type: FLOAT
          units: '%'
          description: 'Free memory of a shared pool expressed in %.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Shared Pool Free %'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 8facfa98bcd3447ea53d0a3d09ada933
              expression: 'max(/Oracle by ODBC/oracle.shared_pool_free,5m)<{$ORACLE.SHARED.FREE.MIN.WARN}'
              name: 'Oracle: Shared pool free is too low'
              event_name: 'Oracle: Shared pool free is too low (less {$ORACLE.SHARED.FREE.MIN.WARN}% for 5m)'
              priority: WARNING
              description: 'The free memory percent of the shared pool has been less than `{$ORACLE.SHARED.FREE.MIN.WARN}`% for the last 5 minutes.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 8b3e958d76d14ef7a6869634106f1277
          name: 'Total sorts per user call'
          type: DEPENDENT
          key: oracle.sorts_per_user_call
          value_type: FLOAT
          description: 'The total sorts per user call.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Total Sorts Per User Call'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: fc2cff59b0804989989179e1dbc338b5
          name: 'Temp space used'
          type: DEPENDENT
          key: oracle.temp_space_used
          value_type: FLOAT
          units: B
          description: 'Used temporary space.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::Temp Space Used'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: 085c097ab3b34f07b262caf80703b469
          name: 'PGA, Total allocated'
          type: DEPENDENT
          key: oracle.total_pga_allocated
          units: B
          description: 'The current amount of the PGA memory allocated by the instance. The Oracle Database attempts to keep this number below the value of the `PGA_AGGREGATE_TARGET` initialization parameter. However, it is possible for the PGA allocated to exceed that value by a small percentage and for a short period of time when the work area workload is increasing very rapidly or when `PGA_AGGREGATE_TARGET` is set to a small value.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''PGA::Total Pga Allocated'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: pga
        - uuid: c2c18a0a502d4fbe91db25d29ae57d45
          name: 'PGA, Total freeable'
          type: DEPENDENT
          key: oracle.total_pga_freeable
          units: B
          description: 'The number of bytes of the PGA memory in all processes that could be freed back to the OS.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''PGA::Total Freeable Pga Memory'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: pga
        - uuid: e0e88ce92ece4ca0b776f09dc4ec5039
          name: 'PGA, Total inuse'
          type: DEPENDENT
          key: oracle.total_pga_used
          units: B
          description: 'The amount of Program Global Area (PGA) memory currently consumed by work areas. This number can be used to determine how much memory is consumed by other consumers of the PGA memory (for example, PL/SQL or Java).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''PGA::Total Pga Inuse'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: pga
        - uuid: 3c817d2b45fc471aa86771ce1739de6f
          name: Uptime
          type: DEPENDENT
          key: oracle.uptime
          trends: '0'
          units: s
          description: 'The Oracle instance uptime expressed in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..UPTIME.first()
          master_item:
            key: 'db.odbc.get[get_instance_state,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 03a4fb1d6e684c9b82c1317699c71468
              expression: 'nodata(/Oracle by ODBC/oracle.uptime,5m)=1'
              name: 'Oracle: Failed to fetch info data'
              event_name: 'Oracle: Failed to fetch info data (or no data for 5m)'
              priority: WARNING
              description: 'Zabbix has not received any data for the items for the last 5 minutes. The database might be unavailable for connecting.'
              dependencies:
                - name: 'Oracle: Port {$ORACLE.PORT} is unavailable'
                  expression: 'max(/Oracle by ODBC/net.tcp.service[tcp,{$ORACLE.HOST},{$ORACLE.PORT}],#3)=0  and max(/Oracle by ODBC/proc.num[,,,"tnslsnr LISTENER"],#3)>0'
              tags:
                - tag: scope
                  value: availability
            - uuid: 431201a1ce0d47948751c7e4e6bbeb92
              expression: 'last(/Oracle by ODBC/oracle.uptime)<10m'
              name: 'Oracle: Host has been restarted'
              event_name: 'Oracle: {HOST.NAME} has been restarted (uptime < 10m)'
              priority: INFO
              description: 'Uptime is less than 10 minutes.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: ad275dbbe8af483b93d37e416c3f1fd2
          name: 'User ''{$ORACLE.USER}'' expire password'
          type: DEPENDENT
          key: oracle.user_expire_password
          value_type: FLOAT
          units: days
          description: 'The number of days before the Zabbix account password expires.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''USER::Expire password'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: a909d8cccacf4470a3e2da88b4e5c3d5
              expression: 'last(/Oracle by ODBC/oracle.user_expire_password)  < {$ORACLE.EXPIRE.PASSWORD.MIN.WARN}'
              name: 'Oracle: Zabbix account will expire soon'
              event_name: 'Oracle: Zabbix account will expire soon (under {$ORACLE.EXPIRE.PASSWORD.MIN.WARN} days)'
              priority: WARNING
              description: 'The password for the Zabbix user in the database expires soon.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 3455378f6ecf4ecb93a69d2387e4a57d
          name: 'User rollbacks per second'
          type: DEPENDENT
          key: oracle.user_rollbacks_rate
          value_type: FLOAT
          units: Rps
          description: 'The number of times that users manually issued the `ROLLBACK` statement or an error occurred during the users'' transactions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.METRIC==''SYS::User Rollbacks Per Sec'')].VALUE.first()'
          master_item:
            key: 'db.odbc.get[get_system_metrics,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
        - uuid: 45143cb0d0284608bf48897885a91bbb
          name: Version
          type: DEPENDENT
          key: oracle.version
          value_type: CHAR
          description: 'The Oracle Server version.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..VERSION.first()
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: 'db.odbc.get[get_instance_state,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: a5dd4fe627c44afebdfe7beeefc4ec3d
              expression: 'last(/Oracle by ODBC/oracle.version,#1)<>last(/Oracle by ODBC/oracle.version,#2) and length(last(/Oracle by ODBC/oracle.version))>0'
              name: 'Oracle: Version has changed'
              event_name: 'Oracle: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              description: 'The Oracle Database version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: bf89a6ced768432a9cc3c27e1e3159d0
          name: 'Number of LISTENER processes'
          key: 'proc.num[,,,"tnslsnr LISTENER"]'
          delay: 30s
          description: 'The number of running listener processes.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: eb5e531eb3f142569775349a126d1ab0
              expression: 'max(/Oracle by ODBC/proc.num[,,,"tnslsnr LISTENER"],#3)=0'
              name: 'Oracle: LISTENER process is not running'
              priority: DISASTER
              description: 'The Oracle listener process is not running.'
              tags:
                - tag: scope
                  value: availability
      discovery_rules:
        - uuid: a527b14b1cee4115be5c5e9387af821b
          name: 'Archive log discovery'
          type: DEPENDENT
          key: oracle.archivelog.discovery
          description: 'Used for the discovery of the log archive.'
          item_prototypes:
            - uuid: 1a6e01f90dca47459975632c14ce5a39
              name: 'Archivelog ''{#DEST_NAME}'': Get archive log info'
              type: ODBC
              key: 'db.odbc.get[get_archivelog_{#DEST_NAME}_stat,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              delay: 5m
              history: '0'
              value_type: TEXT
              params: |
                SELECT
                d.dest_name, DECODE (d.status, 'VALID',3, 'DEFERRED', 2, 'ERROR', 1, 0) AS status,
                d.log_sequence,
                d.error
                FROM v$archive_dest d , v$database db
                WHERE d.dest_name = '{#DEST_NAME}' AND d.status != 'INACTIVE' AND db.log_mode = 'ARCHIVELOG';
              username: '{$ORACLE.USER}'
              password: '{$ORACLE.PASSWORD}'
              description: 'Gets the archive log statistics.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.first()
                  error_handler: DISCARD_VALUE
              tags:
                - tag: component
                  value: archive-log
                - tag: component
                  value: raw
            - uuid: 06e47a56685e4dd784628c40d5038c88
              name: 'Archivelog ''{#DEST_NAME}'': Error'
              type: DEPENDENT
              key: 'oracle.archivelog_error["{#DEST_NAME}"]'
              value_type: TEXT
              description: 'Displays the error message.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.ERROR
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_archivelog_{#DEST_NAME}_stat,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: archive-log
                - tag: destination
                  value: '{#DEST_NAME}'
            - uuid: 1948e6bfaa48451cac6ee83a16b07826
              name: 'Archivelog ''{#DEST_NAME}'': Last sequence'
              type: DEPENDENT
              key: 'oracle.archivelog_log_sequence["{#DEST_NAME}"]'
              description: 'Identifies the sequence number of the last archived redo log to be archived.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.LOG_SEQUENCE
              master_item:
                key: 'db.odbc.get[get_archivelog_{#DEST_NAME}_stat,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: archive-log
                - tag: destination
                  value: '{#DEST_NAME}'
            - uuid: 0d561969fc2942fea854541a03b6a490
              name: 'Archivelog ''{#DEST_NAME}'': Status'
              type: DEPENDENT
              key: 'oracle.archivelog_log_status["{#DEST_NAME}"]'
              description: |
                Identifies the current status of the destination where:
                1 - VALID;
                2 - DEFERRED;
                3 - ERROR;
                0 - UNKNOWN.
              valuemap:
                name: 'Oracle Archivelog status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.STATUS
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'db.odbc.get[get_archivelog_{#DEST_NAME}_stat,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: archive-log
                - tag: destination
                  value: '{#DEST_NAME}'
              trigger_prototypes:
                - uuid: 1202e75015304115a4ccdab027617816
                  expression: 'last(/Oracle by ODBC/oracle.archivelog_log_status["{#DEST_NAME}"])<2'
                  name: 'Oracle: Archivelog ''{#DEST_NAME}'': Log Archive is not valid'
                  priority: HIGH
                  description: |
                    The trigger will launch if the archive log destination is not in one of these states:
                    2 - DEFERRED;
                    3 - VALID.
                  tags:
                    - tag: scope
                      value: availability
          master_item:
            key: 'db.odbc.get[get_archivelog,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          lld_macro_paths:
            - lld_macro: '{#DEST_NAME}'
              path: $.DEST_NAME
        - uuid: c40708b755c7464bb064b7bffc584381
          name: 'ASM disk groups discovery'
          type: DEPENDENT
          key: oracle.asm.discovery
          description: 'Used for discovering the ASM disk groups.'
          item_prototypes:
            - uuid: 63fad55a2ced487aa30017b33bf1692e
              name: 'ASM ''{#DGNAME}'': Get ASM stats'
              type: ODBC
              key: 'db.odbc.get[get_asm_{#DGNAME}_stat,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              history: '0'
              value_type: TEXT
              params: |
                SELECT
                name AS dgname,
                ROUND(total_mb / DECODE(TYPE, 'NORMAL', 2, 'HIGH', 3, 'EXTERN', 1)*1024*1024) AS size_byte,
                ROUND(usable_file_mb*1024*1024 ) AS free_size_byte,
                ROUND(100-(usable_file_mb /(total_mb / DECODE(TYPE, 'NORMAL', 2, 'HIGH', 3, 'EXTERN', 1)))* 100, 2) AS used_percent
                FROM v$asm_diskgroup_stat
                WHERE name = '{#DGNAME}';
              username: '{$ORACLE.USER}'
              password: '{$ORACLE.PASSWORD}'
              description: 'Gets the ASM disk group statistics.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.first()
                  error_handler: DISCARD_VALUE
              tags:
                - tag: component
                  value: asm
                - tag: component
                  value: raw
            - uuid: da6116af9f54452ab1694af8eef9f38d
              name: 'ASM ''{#DGNAME}'': Free size'
              type: DEPENDENT
              key: 'oracle.asm_free_size["{#DGNAME}"]'
              units: B
              description: 'The free size of the ASM disk group.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.FREE_SIZE_BYTE
              master_item:
                key: 'db.odbc.get[get_asm_{#DGNAME}_stat,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: asm
                - tag: disk-group
                  value: '{#DGNAME}'
            - uuid: 7f2a51d7eeb64c5b8929dcb0e3a49273
              name: 'ASM ''{#DGNAME}'': Total size'
              type: DEPENDENT
              key: 'oracle.asm_total_size["{#DGNAME}"]'
              units: B
              description: 'The total size of the ASM disk group.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.SIZE_BYTE
              master_item:
                key: 'db.odbc.get[get_asm_{#DGNAME}_stat,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: asm
                - tag: disk-group
                  value: '{#DGNAME}'
            - uuid: 9c87a9089a19468f85eb1d3c28893092
              name: 'ASM ''{#DGNAME}'': Used size, percent'
              type: DEPENDENT
              key: 'oracle.asm_used_pct["{#DGNAME}"]'
              value_type: FLOAT
              units: '%'
              description: 'Usage of the ASM disk group expressed in %.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.USED_PERCENT
              master_item:
                key: 'db.odbc.get[get_asm_{#DGNAME}_stat,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: asm
                - tag: disk-group
                  value: '{#DGNAME}'
              trigger_prototypes:
                - uuid: 756a8b4b04bc4aadab6b4b4cc856ad32
                  expression: 'min(/Oracle by ODBC/oracle.asm_used_pct["{#DGNAME}"],5m)>{$ORACLE.ASM.USED.PCT.MAX.HIGH}'
                  name: 'Oracle: ASM ''{#DGNAME}'': Disk group usage is too high'
                  event_name: 'Oracle: ASM ''{#DGNAME}'': Disk group usage is too high (over {$ORACLE.ASM.USED.PCT.MAX.HIGH}% for 5m)'
                  priority: HIGH
                  description: 'The usage of the ASM disk group expressed in % exceeds `{$ORACLE.ASM.USED.PCT.MAX.WARN}`.'
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: d65971e0f3994dfcbcbde145c9866678
                  expression: 'min(/Oracle by ODBC/oracle.asm_used_pct["{#DGNAME}"],5m)>{$ORACLE.ASM.USED.PCT.MAX.WARN}'
                  name: 'Oracle: ASM ''{#DGNAME}'': Disk group usage is too high'
                  event_name: 'Oracle: ASM ''{#DGNAME}'': Disk group usage is too high (over {$ORACLE.ASM.USED.PCT.MAX.WARN}% for 5m)'
                  priority: WARNING
                  description: 'The usage of the ASM disk group expressed in % exceeds `{$ORACLE.ASM.USED.PCT.MAX.WARN}`.'
                  dependencies:
                    - name: 'Oracle: ASM ''{#DGNAME}'': Disk group usage is too high'
                      expression: 'min(/Oracle by ODBC/oracle.asm_used_pct["{#DGNAME}"],5m)>{$ORACLE.ASM.USED.PCT.MAX.HIGH}'
                  tags:
                    - tag: scope
                      value: capacity
          graph_prototypes:
            - uuid: 75f9f07dbae84443900aad10095e37f9
              name: 'ASM ''{#DGNAME}'': ASM disk group ''{#DGNAME}'''
              graph_items:
                - color: 199C0D
                  item:
                    host: 'Oracle by ODBC'
                    key: 'oracle.asm_free_size["{#DGNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'Oracle by ODBC'
                    key: 'oracle.asm_total_size["{#DGNAME}"]'
          master_item:
            key: 'db.odbc.get[get_asm,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          lld_macro_paths:
            - lld_macro: '{#DGNAME}'
              path: $.DGNAME
        - uuid: 0f65936b86314c269b7720a9ff3f1c14
          name: 'Database discovery'
          type: DEPENDENT
          key: oracle.db.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DBNAME}'
                value: '{$ORACLE.DBNAME.MATCHES}'
              - macro: '{#DBNAME}'
                value: '{$ORACLE.DBNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Used for database discovery.'
          item_prototypes:
            - uuid: 5de7c786988d49d0b50f28d2d622db62
              name: 'Database ''{#DBNAME}'': Get CDB and No-CDB info'
              type: ODBC
              key: 'db.odbc.get[get_cdb_{#DBNAME}_info,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              history: '0'
              value_type: TEXT
              params: |
                SELECT name as DBNAME,
                DECODE(open_mode, 'MOUNTED', 1, 'READ ONLY', 2, 'READ WRITE', 3, 'READ ONLY WITH APPLY', 4, 'MIGRATE', 5, 0) AS open_mode,
                DECODE(database_role, 'SNAPSHOT STANDBY', 1, 'LOGICAL STANDBY', 2, 'PHYSICAL STANDBY', 3, 'PRIMARY', 4, 'FAR SYNC', 5, 0) AS ROLE,
                DECODE(force_logging, 'YES',1,'NO',0,0) AS force_logging,
                DECODE(log_mode, 'MANUAL',2 ,'ARCHIVELOG',1,'NOARCHIVELOG',0,0) AS log_mode
                FROM v$database
                WHERE name = '{#DBNAME}';
              username: '{$ORACLE.USER}'
              password: '{$ORACLE.PASSWORD}'
              description: 'Gets the information about the CDB and non-CDB database on an instance.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.first()
                  error_handler: DISCARD_VALUE
              tags:
                - tag: component
                  value: cdb
                - tag: component
                  value: raw
            - uuid: 075885bfd41d43aba7861ae49e9abbee
              name: 'Database ''{#DBNAME}'': Force logging'
              type: DEPENDENT
              key: 'oracle.db_force_logging["{#DBNAME}"]'
              description: 'Indicates whether the database is under force logging mode (`YES`/`NO`).'
              valuemap:
                name: 'Oracle force log status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.FORCE_LOGGING
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'db.odbc.get[get_cdb_{#DBNAME}_info,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
                - tag: type
                  value: '{#TYPE}'
            - uuid: 9b88e24d523e4111b2ff65ae26650e04
              name: 'Database ''{#DBNAME}'': Log mode'
              type: DEPENDENT
              key: 'oracle.db_log_mode["{#DBNAME}"]'
              description: |
                The archive log mode where:
                0 - NOARCHIVELOG;
                1 - ARCHIVELOG;
                2 - MANUAL.
              valuemap:
                name: 'Oracle log mode'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.LOG_MODE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'db.odbc.get[get_cdb_{#DBNAME}_info,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
                - tag: type
                  value: '{#TYPE}'
            - uuid: f1971909355f4ef48c32695b5d204d56
              name: 'Database ''{#DBNAME}'': Open status'
              type: DEPENDENT
              key: 'oracle.db_open_mode["{#DBNAME}"]'
              description: |
                1 - MOUNTED;
                2 - READ WRITE;
                3 - READ ONLY;
                4 - READ ONLY WITH APPLY (a physical standby database is open in real-time query mode).
              valuemap:
                name: 'Oracle DB open status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.OPEN_MODE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'db.odbc.get[get_cdb_{#DBNAME}_info,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
                - tag: type
                  value: '{#TYPE}'
              trigger_prototypes:
                - uuid: 9bf80a9372ef4b3898fd5a4f0c3cec7c
                  expression: 'last(/Oracle by ODBC/oracle.db_open_mode["{#DBNAME}"],#1)<>last(/Oracle by ODBC/oracle.db_open_mode["{#DBNAME}"],#2)'
                  name: 'Oracle: Database ''{#DBNAME}'': Open status has changed'
                  event_name: 'Oracle: Database ''{#DBNAME}'': Open status has changed (new value received: {ITEM.VALUE})'
                  priority: INFO
                  description: 'The Oracle Database open status has changed. Acknowledge to close the problem manually.'
                  manual_close: 'YES'
                  dependencies:
                    - name: 'Oracle: Database ''{#DBNAME}'': Open status in mount mode'
                      expression: 'last(/Oracle by ODBC/oracle.db_open_mode["{#DBNAME}"])=1'
                  tags:
                    - tag: scope
                      value: notice
                - uuid: 3620ac4e75644789a2f0245dbb948771
                  expression: 'last(/Oracle by ODBC/oracle.db_open_mode["{#DBNAME}"])=1'
                  name: 'Oracle: Database ''{#DBNAME}'': Open status in mount mode'
                  priority: WARNING
                  description: 'The Oracle Database is in a mounted state.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 949d1e5fc4424b2bb0ffd220f00f6a79
              name: 'Database ''{#DBNAME}'': Role'
              type: DEPENDENT
              key: 'oracle.db_role["{#DBNAME}"]'
              description: |
                The current role of the database where:
                1 - SNAPSHOT STANDBY;
                2 - LOGICAL STANDBY;
                3 - PHYSICAL STANDBY;
                4 - PRIMARY;
                5 - FAR SYNC.
              valuemap:
                name: 'Oracle DB role'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.ROLE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'db.odbc.get[get_cdb_{#DBNAME}_info,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
                - tag: type
                  value: '{#TYPE}'
              trigger_prototypes:
                - uuid: fb5ccc917a8344d7945b8867a1982d6b
                  expression: 'last(/Oracle by ODBC/oracle.db_role["{#DBNAME}"],#1)<>last(/Oracle by ODBC/oracle.db_role["{#DBNAME}"],#2)'
                  name: 'Oracle: Database ''{#DBNAME}'': Role has changed'
                  event_name: 'Oracle: Database ''{#DBNAME}'': Role has changed (new value received: {ITEM.VALUE})'
                  priority: INFO
                  description: 'The Oracle Database role has changed. Acknowledge to close the problem manually.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: notice
          trigger_prototypes:
            - uuid: 9c17e0fdd6fe409e8f298433e58b7445
              expression: 'last(/Oracle by ODBC/oracle.db_force_logging["{#DBNAME}"]) = 0 and last(/Oracle by ODBC/oracle.db_log_mode["{#DBNAME}"]) = 1'
              name: 'Oracle: Database ''{#DBNAME}'': Force logging is deactivated for DB with active Archivelog'
              priority: WARNING
              description: 'Force logging mode is a very important metric for databases in `ARCHIVELOG`. This feature allows to forcibly write all the transactions to the redo log.'
              tags:
                - tag: scope
                  value: performance
          master_item:
            key: 'db.odbc.get[get_db,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          lld_macro_paths:
            - lld_macro: '{#DBNAME}'
              path: $.DBNAME
            - lld_macro: '{#TYPE}'
              path: $.TYPE
        - uuid: 2611e69f735a42b190852589658dd591
          name: 'PDB discovery'
          type: DEPENDENT
          key: oracle.pdb.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DBNAME}'
                value: '{$ORACLE.DBNAME.MATCHES}'
              - macro: '{#DBNAME}'
                value: '{$ORACLE.DBNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Used for the discovery of the pluggable database (PDB).'
          item_prototypes:
            - uuid: cedcebd0b7ce474c9681022fcc75df1c
              name: 'Database ''{#DBNAME}'': Get PDB info'
              type: ODBC
              key: 'db.odbc.get[get_pdb_{#CON_ID}_info,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              history: '0'
              value_type: TEXT
              params: |
                SELECT
                name as DBNAME,
                DECODE(open_mode, 'MOUNTED', 1, 'READ ONLY', 2, 'READ WRITE', 3, 'READ ONLY WITH APPLY', 4, 'MIGRATE', 5, 0) AS open_mode
                FROM v$pdbs
                WHERE CON_ID = '{#CON_ID}';
              username: '{$ORACLE.USER}'
              password: '{$ORACLE.PASSWORD}'
              description: 'Gets the information about the PDB database on an instance.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.first()
                  error_handler: DISCARD_VALUE
              tags:
                - tag: component
                  value: pdb
                - tag: component
                  value: raw
            - uuid: 975d302e3e9a4316b6d63256b88b5006
              name: 'Database ''{#DBNAME}'': Open status'
              type: DEPENDENT
              key: 'oracle.pdb_open_mode["{#CON_ID}"]'
              description: |
                1 - MOUNTED;
                2 - READ WRITE;
                3 - READ ONLY;
                4 - READ ONLY WITH APPLY (a physical standby database is open in real-time query mode).
              valuemap:
                name: 'Oracle DB open status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.OPEN_MODE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'db.odbc.get[get_pdb_{#CON_ID}_info,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
                - tag: type
                  value: pdb
              trigger_prototypes:
                - uuid: 3dbb9379f8024924b197037acfbbdac4
                  expression: 'last(/Oracle by ODBC/oracle.pdb_open_mode["{#CON_ID}"],#1)<>last(/Oracle by ODBC/oracle.pdb_open_mode["{#CON_ID}"],#2)'
                  name: 'Oracle: Database ''{#DBNAME}'': Open status has changed'
                  event_name: 'Oracle: Database ''{#DBNAME}'': Open status has changed (new value received: {ITEM.VALUE})'
                  priority: INFO
                  description: 'The Oracle Database open status has changed. Acknowledge to close the problem manually.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: notice
                - uuid: 5f8ed69b2c074a29b9975baf10a2a2f8
                  expression: 'last(/Oracle by ODBC/oracle.pdb_open_mode["{#CON_ID}"])=1'
                  name: 'Oracle: Database ''{#DBNAME}'': Open status in mount mode'
                  priority: WARNING
                  description: 'The Oracle Database is in a mounted state.'
                  tags:
                    - tag: scope
                      value: notice
          master_item:
            key: 'db.odbc.get[get_pdb,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          lld_macro_paths:
            - lld_macro: '{#CON_ID}'
              path: $.CON_ID
            - lld_macro: '{#DBNAME}'
              path: $.DBNAME
        - uuid: c8de553c98f64e59b40bf927f6447ad1
          name: 'Tablespace discovery'
          type: DEPENDENT
          key: oracle.tablespace.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CON_NAME}'
                value: '{$ORACLE.TABLESPACE.CONTAINER.MATCHES}'
              - macro: '{#CON_NAME}'
                value: '{$ORACLE.TABLESPACE.CONTAINER.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#TABLESPACE}'
                value: '{$ORACLE.TABLESPACE.NAME.MATCHES}'
              - macro: '{#TABLESPACE}'
                value: '{$ORACLE.TABLESPACE.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Used for the discovery of tablespaces in DBMS.'
          item_prototypes:
            - uuid: 972be2e777e44c539d0ddd7918b79e88
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Get tablespaces stats'
              type: ODBC
              key: 'db.odbc.get[get_{#CON_ID}_tablespace_{#TABLESPACE}_stats,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              history: '0'
              value_type: TEXT
              params: |
                SELECT df.CON_NAME,
                       df.TABLESPACE_NAME                  AS TABLESPACE,
                       df.CONTENTS                         AS TYPE,
                       NVL(SUM(df.BYTES), 0)               AS FILE_BYTES,
                       NVL(SUM(df.MAX_BYTES), 0)           AS MAX_BYTES,
                       NVL(SUM(f.FREE), 0)                 AS FREE_BYTES,
                       NVL(SUM(df.BYTES) - SUM(f.FREE), 0) AS USED_BYTES,
                       ROUND(CASE SUM(df.MAX_BYTES)
                                 WHEN 0 THEN 0
                                 ELSE (SUM(df.BYTES) / SUM(df.MAX_BYTES) * 100)
                                 END, 2)                   AS USED_PCT_MAX,
                       ROUND(CASE SUM(df.BYTES)
                                 WHEN 0 THEN 0
                                 ELSE (NVL(SUM(df.BYTES) - SUM(f.FREE), 0)) / SUM(df.BYTES) * 100
                                 END, 2)                   AS USED_FILE_PCT,
                       ROUND(CASE SUM(df.MAX_BYTES)
                                 WHEN 0 THEN 0
                                 ELSE NVL(SUM(df.BYTES) - SUM(f.FREE), 0) / SUM(df.MAX_BYTES) * 100
                                 END, 2)                   AS USED_FROM_MAX_PCT,
                       CASE df.STATUS
                           WHEN 'ONLINE' THEN 1
                           WHEN 'OFFLINE' THEN 2
                           WHEN 'READ ONLY' THEN 3
                           ELSE 0
                           END                             AS STATUS
                FROM (SELECT ct.CON$NAME                              AS CON_NAME,
                             cdf.FILE_ID,
                             ct.CONTENTS,
                             ct.STATUS,
                             cdf.FILE_NAME,
                             cdf.TABLESPACE_NAME,
                             TRUNC(cdf.BYTES)                         AS BYTES,
                             TRUNC(GREATEST(cdf.BYTES, cdf.MAXBYTES)) AS MAX_BYTES
                      FROM CDB_DATA_FILES cdf,
                           CDB_TABLESPACES ct
                      WHERE cdf.TABLESPACE_NAME = ct.TABLESPACE_NAME
                        AND cdf.CON_ID = ct.CON_ID
                        AND (ct.CON_ID = '{#CON_ID}' or (ct.CON$NAME is null and ct.CON_ID = 0))
                        AND cdf.TABLESPACE_NAME = '{#TABLESPACE}'
                        AND ct.CONTENTS = '{#CONTENTS}') df,
                     (SELECT TRUNC(SUM(BYTES)) AS FREE,
                             FILE_ID
                      FROM CDB_FREE_SPACE
                      GROUP BY FILE_ID) f
                WHERE df.FILE_ID = f.FILE_ID (+)
                GROUP BY df.CON_NAME,
                         df.TABLESPACE_NAME,
                         df.CONTENTS,
                         df.STATUS
                UNION ALL
                SELECT Y.CON_NAME,
                       Y.NAME                                   AS TABLESPACE,
                       Y.CONTENTS                               AS TYPE,
                       NVL(SUM(Y.BYTES), 0)                     AS FILE_BYTES,
                       NVL(SUM(Y.MAX_BYTES), 0)                 AS MAX_BYTES,
                       NVL(MAX(NVL(Y.FREE_BYTES, 0)), 0)        AS FREE_BYTES,
                       NVL(SUM(Y.BYTES) - MAX(Y.FREE_BYTES), 0) AS USED_BYTES,
                       ROUND(CASE SUM(Y.MAX_BYTES)
                                 WHEN 0 THEN 0
                                 ELSE (SUM(Y.BYTES) / SUM(Y.MAX_BYTES) * 100)
                                 END, 2)                                    AS USED_PCT_MAX,
                       ROUND(CASE SUM(Y.BYTES)
                                 WHEN 0 THEN 0
                                 ELSE (NVL(SUM(Y.BYTES) - MAX(Y.FREE_BYTES), 0)) / SUM(Y.BYTES) * 100
                                 END, 2)                                    AS USED_FILE_PCT,
                       ROUND(CASE SUM(Y.MAX_BYTES)
                                 WHEN 0 THEN 0
                                 ELSE (NVL(SUM(Y.BYTES) - MAX(Y.FREE_BYTES), 0)) / SUM(Y.MAX_BYTES) * 100
                                 END, 2)                                    AS USED_FROM_MAX_PCT,
                       CASE Y.STATUS
                           WHEN 'ONLINE' THEN 1
                           WHEN 'OFFLINE' THEN 2
                           WHEN 'READ ONLY' THEN 3
                           ELSE 0
                           END                                  AS STATUS
                FROM (SELECT ct.CON$NAME                  AS CON_NAME,
                             ctf.TABLESPACE_NAME          AS NAME,
                             ct.CONTENTS,
                             ctf.STATUS                   AS STATUS,
                             ctf.BYTES                    AS BYTES,
                             (SELECT ((f.TOTAL_BLOCKS - s.TOT_USED_BLOCKS) * vp.VALUE)
                              FROM (SELECT CON_ID,
                                           TABLESPACE_NAME,
                                           SUM(USED_BLOCKS) TOT_USED_BLOCKS
                                    FROM V$SORT_SEGMENT
                                    WHERE TABLESPACE_NAME != 'DUMMY'
                                    GROUP BY CON_ID,
                                             TABLESPACE_NAME) s,
                                   (SELECT CON_ID,
                                           TABLESPACE_NAME,
                                           SUM(BLOCKS) TOTAL_BLOCKS
                                    FROM CDB_TEMP_FILES
                                    WHERE TABLESPACE_NAME != 'DUMMY'
                                    GROUP BY CON_ID,
                                             TABLESPACE_NAME) f,
                                   (SELECT VALUE
                                    FROM V$PARAMETER
                                    WHERE NAME = 'db_block_size') vp
                              WHERE f.TABLESPACE_NAME = s.TABLESPACE_NAME
                                AND f.TABLESPACE_NAME = ctf.TABLESPACE_NAME
                                AND f.CON_ID = s.CON_ID
                                AND f.CON_ID = ct.CON_ID) AS FREE_BYTES,
                             CASE
                                 WHEN ctf.MAXBYTES = 0 THEN ctf.BYTES
                                 ELSE ctf.MAXBYTES
                                 END                      AS MAX_BYTES
                      FROM CDB_TEMP_FILES ctf,
                           CDB_TABLESPACES ct
                      WHERE ctf.TABLESPACE_NAME = ct.TABLESPACE_NAME
                        AND ctf.CON_ID = ct.CON_ID
                        AND (ct.CON_ID = '{#CON_ID}' or (ct.CON$NAME is null and ct.CON_ID = 0))
                        AND ctf.TABLESPACE_NAME = '{#TABLESPACE}'
                        AND ct.CONTENTS = '{#CONTENTS}') Y
                GROUP BY Y.CON_NAME,
                         Y.NAME,
                         Y.CONTENTS,
                         Y.STATUS;
              username: '{$ORACLE.USER}'
              password: '{$ORACLE.PASSWORD}'
              description: 'Gets the statistics of the tablespace.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.first()
                  error_handler: DISCARD_VALUE
              tags:
                - tag: component
                  value: raw
                - tag: component
                  value: tablespaces
            - uuid: 46956fd7e5d8462798b85cd7b425a794
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace allocated, bytes'
              type: DEPENDENT
              key: 'oracle.tbs_alloc_bytes["{#CON_ID}","{#TABLESPACE}"]'
              units: B
              description: 'Currently allocated bytes for the tablespace (sum of the current size of datafiles).'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.FILE_BYTES
              master_item:
                key: 'db.odbc.get[get_{#CON_ID}_tablespace_{#TABLESPACE}_stats,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
            - uuid: 8c3284a21872423499ee15fd7b0038f1
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace free, bytes'
              type: DEPENDENT
              key: 'oracle.tbs_free_bytes["{#CON_ID}","{#TABLESPACE}"]'
              units: B
              description: 'Free bytes of the allocated space.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.FREE_BYTES
              master_item:
                key: 'db.odbc.get[get_{#CON_ID}_tablespace_{#TABLESPACE}_stats,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
            - uuid: afd8c1a01b64408fbc6f8f95fbb13593
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace MAX size, bytes'
              type: DEPENDENT
              key: 'oracle.tbs_max_bytes["{#CON_ID}","{#TABLESPACE}"]'
              units: B
              description: 'The maximum size of the tablespace.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.MAX_BYTES
              master_item:
                key: 'db.odbc.get[get_{#CON_ID}_tablespace_{#TABLESPACE}_stats,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
            - uuid: 42c7812a75d5433ab8a275498635c81c
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Open status'
              type: DEPENDENT
              key: 'oracle.tbs_status["{#CON_ID}","{#TABLESPACE}"]'
              description: |
                The tablespace status where:
                1 - ONLINE;
                2 - OFFLINE;
                3 - READ ONLY.
              valuemap:
                name: 'Oracle tablespace status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.STATUS
              master_item:
                key: 'db.odbc.get[get_{#CON_ID}_tablespace_{#TABLESPACE}_stats,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
              trigger_prototypes:
                - uuid: 3c5f54f41f95440aa18ca5316aeb50f6
                  expression: 'last(/Oracle by ODBC/oracle.tbs_status["{#CON_ID}","{#TABLESPACE}"])=2'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace is OFFLINE'
                  priority: WARNING
                  description: 'The tablespace is in the offline state.'
                  tags:
                    - tag: scope
                      value: availability
                - uuid: 05c2af5a765842a1a70f2f67355db1b3
                  expression: 'last(/Oracle by ODBC/oracle.tbs_status["{#CON_ID}","{#TABLESPACE}"],#1)<>last(/Oracle by ODBC/oracle.tbs_status["{#CON_ID}","{#TABLESPACE}"],#2)'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace status has changed'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace status has changed (new value received: {ITEM.VALUE})'
                  priority: INFO
                  description: 'Oracle tablespace status has changed. Acknowledge to close the problem manually.'
                  manual_close: 'YES'
                  dependencies:
                    - name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace is OFFLINE'
                      expression: 'last(/Oracle by ODBC/oracle.tbs_status["{#CON_ID}","{#TABLESPACE}"])=2'
                  tags:
                    - tag: scope
                      value: capacity
            - uuid: b9cc0eabdcbc404fb0df2a2a082411f1
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace used, bytes'
              type: DEPENDENT
              key: 'oracle.tbs_used_bytes["{#CON_ID}","{#TABLESPACE}"]'
              units: B
              description: 'Currently used bytes for the tablespace (current size of datafiles minus the free space).'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.USED_BYTES
              master_item:
                key: 'db.odbc.get[get_{#CON_ID}_tablespace_{#TABLESPACE}_stats,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
            - uuid: 877961c286e448238f58cff9c51088c8
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage, percent'
              type: DEPENDENT
              key: 'oracle.tbs_used_file_pct["{#CON_ID}","{#TABLESPACE}"]'
              value_type: FLOAT
              units: '%'
              description: 'Used bytes/allocated bytes*100.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.USED_FILE_PCT
              master_item:
                key: 'db.odbc.get[get_{#CON_ID}_tablespace_{#TABLESPACE}_stats,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
              trigger_prototypes:
                - uuid: 78c293ae7ded42b0b05d50af99762017
                  expression: 'min(/Oracle by ODBC/oracle.tbs_used_file_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.MAX.HIGH}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage is too high (over {$ORACLE.TBS.USED.PCT.MAX.HIGH}% for 5m).'
                  priority: HIGH
                  description: 'The usage of the tablespace `{#TABLESPACE}` exceeds `{$ORACLE.TBS.USED.PCT.MAX.HIGH}`%'
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: e6f2cb4ade52464b97f5e0f5e05ab61b
                  expression: 'min(/Oracle by ODBC/oracle.tbs_used_file_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.MAX.WARN}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage is too high (over {$ORACLE.TBS.USED.PCT.MAX.WARN}% for 5m).'
                  priority: WARNING
                  description: 'The usage of the tablespace `{#TABLESPACE}` exceeds `{$ORACLE.TBS.USED.PCT.MAX.WARN}`%'
                  dependencies:
                    - name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage is too high'
                      expression: 'min(/Oracle by ODBC/oracle.tbs_used_file_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.MAX.HIGH}'
                  tags:
                    - tag: scope
                      value: capacity
            - uuid: 94ecf43024cd41cf891df319cc615b50
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage from MAX, percent'
              type: DEPENDENT
              key: 'oracle.tbs_used_from_max_pct["{#CON_ID}","{#TABLESPACE}"]'
              value_type: FLOAT
              units: '%'
              description: 'Used bytes/max bytes*100.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.USED_FROM_MAX_PCT
              master_item:
                key: 'db.odbc.get[get_{#CON_ID}_tablespace_{#TABLESPACE}_stats,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
              trigger_prototypes:
                - uuid: 1db3eee269ea4554bc363338868c8830
                  expression: 'min(/Oracle by ODBC/oracle.tbs_used_from_max_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.FROM.MAX.HIGH}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage from MAX is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage from MAX is too high (over {$ORACLE.TBS.USED.PCT.FROM.MAX.HIGH}% for 5m).'
                  priority: HIGH
                  description: 'The usage of the tablespace `{#TABLESPACE}` from MAX exceeds `{$ORACLE.TBS.USED.PCT.FROM.MAX.HIGH}`%'
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: 062309da61ff407eb96201f530544a02
                  expression: 'min(/Oracle by ODBC/oracle.tbs_used_from_max_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.FROM.MAX.WARN}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage from MAX is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage from MAX is too high (over {$ORACLE.TBS.USED.PCT.FROM.MAX.WARN}% for 5m).'
                  priority: WARNING
                  description: 'The usage of the tablespace `{#TABLESPACE}` from MAX exceeds `{$ORACLE.TBS.USED.PCT.FROM.MAX.WARN}`%'
                  dependencies:
                    - name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage from MAX is too high'
                      expression: 'min(/Oracle by ODBC/oracle.tbs_used_from_max_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.FROM.MAX.HIGH}'
                  tags:
                    - tag: scope
                      value: capacity
            - uuid: c3a904455ff244e1a30bf32f0b4ea0d7
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace allocated, percent'
              type: DEPENDENT
              key: 'oracle.tbs_used_pct["{#CON_ID}","{#TABLESPACE}"]'
              value_type: FLOAT
              units: '%'
              description: 'Allocated bytes/max bytes*100.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.USED_PCT_MAX
              master_item:
                key: 'db.odbc.get[get_{#CON_ID}_tablespace_{#TABLESPACE}_stats,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
              trigger_prototypes:
                - uuid: a8aa7255866d4a5ba71d2f89a1d234fe
                  expression: 'min(/Oracle by ODBC/oracle.tbs_used_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.UTIL.PCT.MAX.HIGH}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization is too high (over {$ORACLE.TBS.UTIL.PCT.MAX.HIGH}% for 5m).'
                  priority: HIGH
                  description: 'The utilization of the tablespace `{#TABLESPACE}` exceeds `{$ORACLE.TBS.UTIL.PCT.MAX.HIGH}`%'
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: 9469e51bd69e4baba82de4fd4e5eb14c
                  expression: 'min(/Oracle by ODBC/oracle.tbs_used_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.UTIL.PCT.MAX.WARN}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization is too high (over {$ORACLE.TBS.UTIL.PCT.MAX.WARN}% for 5m).'
                  priority: WARNING
                  description: 'The utilization of the tablespace `{#TABLESPACE}` exceeds `{$ORACLE.TBS.UTIL.PCT.MAX.WARN}`%'
                  dependencies:
                    - name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization is too high'
                      expression: 'min(/Oracle by ODBC/oracle.tbs_used_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.UTIL.PCT.MAX.HIGH}'
                  tags:
                    - tag: scope
                      value: capacity
          graph_prototypes:
            - uuid: a9f3bc52aa0340feb35600ad249e82d3
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace ''{#TABLESPACE}'''
              graph_items:
                - color: 199C0D
                  item:
                    host: 'Oracle by ODBC'
                    key: 'oracle.tbs_alloc_bytes["{#CON_ID}","{#TABLESPACE}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'Oracle by ODBC'
                    key: 'oracle.tbs_max_bytes["{#CON_ID}","{#TABLESPACE}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'Oracle by ODBC'
                    key: 'oracle.tbs_used_bytes["{#CON_ID}","{#TABLESPACE}"]'
          master_item:
            key: 'db.odbc.get[get_tablespace,,"Driver={$ORACLE.DRIVER};DBQ=//{$ORACLE.HOST}:{$ORACLE.PORT}/{$ORACLE.SERVICE};"]'
          lld_macro_paths:
            - lld_macro: '{#CONTENTS}'
              path: $.CONTENTS
            - lld_macro: '{#CON_ID}'
              path: $.CON_ID
            - lld_macro: '{#CON_NAME}'
              path: $.CON_NAME
            - lld_macro: '{#TABLESPACE}'
              path: $.TABLESPACE
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: oracle
      macros:
        - macro: '{$ORACLE.ASM.USED.PCT.MAX.HIGH}'
          value: '95'
          description: 'The maximum percentage of used space in the Automatic Storage Management (ASM) disk group for the High trigger expression.'
          config:
            type: TEXT
            priority: '31'
            section_name: Thresholds
            label: 'High threshold for used space in the ASM'
            description: 'Maximum percentage of used space in the Automatic Storage Management (ASM) disk group for the High trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.ASM.USED.PCT.MAX.WARN}'
          value: '90'
          description: 'The maximum percentage of used space in the Automatic Storage Management (ASM) disk group for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '30'
            section_name: Thresholds
            label: 'Warning threshold for used space in the ASM'
            description: 'Maximum percentage of used space in the Automatic Storage Management (ASM) disk group for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.CONCURRENCY.MAX.WARN}'
          value: '80'
          description: 'The maximum percentage of session concurrency for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '26'
            section_name: Thresholds
            label: 'Warning threshold for session concurrency'
            description: 'Maximum percentage of session concurrency for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.DB.FILE.MAX.WARN}'
          value: '80'
          description: 'The maximum percentage of used database files for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '21'
            section_name: Thresholds
            label: 'Warning threshold for used database files'
            description: 'Maximum percentage of used database files for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.DBNAME.MATCHES}'
          value: '.*'
          description: 'Used in database discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '7'
            section_name: Filters
            label: 'Include database filter'
            description: 'Regex string to include discovered database.'
        - macro: '{$ORACLE.DBNAME.NOT_MATCHES}'
          value: PDB\$SEED
          description: 'Used in database discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '8'
            section_name: Filters
            label: 'Exclude database filter'
            description: 'Regex string to exclude discovered database.'
        - macro: '{$ORACLE.DRIVER}'
          description: 'Oracle driver path. For example: `/usr/lib/oracle/21/client64/lib/libsqora.so.21.1`'
          config:
            type: TEXT
            priority: '1'
            label: 'Oracle driver path'
            required: 'YES'
        - macro: '{$ORACLE.EXPIRE.PASSWORD.MIN.WARN}'
          value: '7'
          description: 'The number of days before the password expires for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '29'
            section_name: Thresholds
            label: 'Warning threshold in days before the password expires'
            description: 'Number of days before the password expires for the Warning trigger expression.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.HOST}'
          description: 'The hostname or IP address of the Oracle DB instance.'
          config:
            type: TEXT
            priority: '5'
            label: 'Oracle URL'
            description: 'Hostname or IP address of the Oracle DB instance.'
            required: 'YES'
        - macro: '{$ORACLE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Oracle user''s password.'
          config:
            type: TEXT
            priority: '4'
            label: Password
            description: 'Oracle database password.'
            required: 'YES'
        - macro: '{$ORACLE.PGA.USE.MAX.WARN}'
          value: '90'
          description: 'Alert threshold for the maximum percentage of the Program Global Area (PGA) usage for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '22'
            section_name: Thresholds
            label: 'Warning threshold for PGA usage'
            description: 'Alert threshold for the maximum percentage of the Program Global Area (PGA) usage for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.PORT}'
          value: '1521'
          description: 'Oracle Database TCP port.'
          config:
            type: TEXT
            priority: '6'
            label: 'Oracle port'
            description: 'Oracle database TCP port. In the range from 1 to 65535 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.PROCESSES.MAX.WARN}'
          value: '80'
          description: 'Alert threshold for the maximum percentage of active processes for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '19'
            section_name: Thresholds
            label: 'Warning threshold for active processes'
            description: 'Alert threshold for the maximum percentage of active processes for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.REDO.MIN.WARN}'
          value: '3'
          description: 'Alert threshold for the minimum number of redo logs for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '27'
            section_name: Thresholds
            label: 'Warning threshold for minimum number of redo logs'
            description: 'Alert threshold for the minimum number of redo logs for the Warning trigger expression.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.SERVICE}'
          description: 'Oracle Service Name.'
          config:
            type: TEXT
            priority: '2'
            label: 'Oracle Service Name'
            required: 'YES'
        - macro: '{$ORACLE.SESSION.LOCK.MAX.TIME}'
          value: '600'
          description: 'The maximum duration of the session lock in seconds to count the session as a prolongedly locked query.'
          config:
            type: TEXT
            priority: '24'
            section_name: Thresholds
            label: 'Duration of the session lock'
            description: 'Maximum duration of the session lock in seconds to count the session as a prolongedly locked query.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.SESSION.LONG.LOCK.MAX.WARN}'
          value: '3'
          description: 'Alert threshold for the maximum number of the prolongedly locked sessions for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '25'
            section_name: Thresholds
            label: 'Warning threshold for prolongedly locked sessions'
            description: 'Alert threshold for the maximum number of the prolongedly locked sessions for the Warning trigger expression.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.SESSIONS.LOCK.MAX.WARN}'
          value: '20'
          description: 'Alert threshold for the maximum percentage of locked sessions for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '23'
            section_name: Thresholds
            label: 'Warning threshold for locked sessions'
            description: 'Alert threshold for the maximum percentage of locked sessions for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.SESSIONS.MAX.WARN}'
          value: '80'
          description: 'Alert threshold for the maximum percentage of active sessions for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '20'
            section_name: Thresholds
            label: 'Warning threshold for active sessions'
            description: 'Alert threshold for the maximum percentage of active sessions for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.SHARED.FREE.MIN.WARN}'
          value: '5'
          description: 'Alert threshold for the minimum percentage of free shared pool for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '28'
            section_name: Thresholds
            label: 'Warning threshold for free shared pool'
            description: 'Alert threshold for the minimum percentage of free shared pool for the Warning trigger expression.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TABLESPACE.CONTAINER.MATCHES}'
          value: '.*'
          description: 'Used in tablespace discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '9'
            section_name: Filters
            label: 'Include tablespace container filter'
            description: 'Regex string to include discovered tablespace container.'
        - macro: '{$ORACLE.TABLESPACE.CONTAINER.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Used in tablespace discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '10'
            section_name: Filters
            label: 'Exclude tablespace container filter'
            description: 'Regex string to exclude discovered tablespace container.'
        - macro: '{$ORACLE.TABLESPACE.NAME.MATCHES}'
          value: '.*'
          description: 'Used in tablespace discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '11'
            section_name: Filters
            label: 'Include tablespace name filter'
            description: 'Regex string to include discovered tablespace.'
        - macro: '{$ORACLE.TABLESPACE.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Used in tablespace discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '12'
            section_name: Filters
            label: 'Exclude tablespace name filter'
            description: 'Regex string to exclude discovered tablespace.'
        - macro: '{$ORACLE.TBS.USED.PCT.FROM.MAX.HIGH}'
          value: '95'
          description: 'High severity alert threshold for the maximum percentage of tablespace usage (used bytes/max bytes) for the High trigger expression.'
          config:
            type: TEXT
            priority: '14'
            section_name: Thresholds
            label: 'High severity alert threshold for from maximum tablespace size'
            description: 'High severity alert threshold for the maximum percentage of tablespace usage (used bytes/max bytes) for the High trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TBS.USED.PCT.FROM.MAX.WARN}'
          value: '90'
          description: 'Warning severity alert threshold for the maximum percentage of tablespace usage from maximum tablespace size (used bytes/max bytes) for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '13'
            section_name: Thresholds
            label: 'Warning severity alert threshold for from maximum tablespace size'
            description: 'Warning severity alert threshold for the maximum percentage of tablespace usage from maximum tablespace size (used bytes/max bytes) for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TBS.USED.PCT.MAX.HIGH}'
          value: '95'
          description: 'High severity alert threshold for the maximum percentage of tablespace usage (used bytes/allocated bytes) for the High trigger expression.'
          config:
            type: TEXT
            priority: '16'
            section_name: Thresholds
            label: 'High severity alert threshold for the maximum percentage of tablespace usage'
            description: 'High severity alert threshold for the maximum percentage of tablespace usage (used bytes/allocated bytes) for the High trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TBS.USED.PCT.MAX.WARN}'
          value: '90'
          description: 'Warning severity alert threshold for the maximum percentage of tablespace usage (used bytes/allocated bytes) for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '15'
            section_name: Thresholds
            label: 'Warning severity alert threshold for the maximum percentage of tablespace usage'
            description: 'Warning severity alert threshold for the maximum percentage of tablespace usage (used bytes/allocated bytes) for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TBS.UTIL.PCT.MAX.HIGH}'
          value: '90'
          description: 'High severity alert threshold for the maximum percentage of tablespace utilization (allocated bytes/max bytes) for the High trigger expression.'
          config:
            type: TEXT
            priority: '18'
            section_name: Thresholds
            label: 'High severity alert threshold for tablespace utilization'
            description: 'High severity alert threshold for the maximum percentage of tablespace utilization (allocated bytes/max bytes) for the High trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TBS.UTIL.PCT.MAX.WARN}'
          value: '80'
          description: 'Warning severity alert threshold for the maximum percentage of tablespace utilization (allocated bytes/max bytes) for the High trigger expression.'
          config:
            type: TEXT
            priority: '17'
            section_name: Thresholds
            label: 'Warning severity alert threshold for tablespace utilization'
            description: 'Warning severity alert threshold for the maximum percentage of tablespace utilization (allocated bytes/max bytes) for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.USER}'
          description: 'Oracle username.'
          config:
            type: TEXT
            priority: '3'
            label: Username
            description: 'Oracle database username.'
            required: 'YES'
      dashboards:
        - uuid: 8bb7593dc22d43d5ba7a16cb7b94d8a3
          name: 'Oracle Performance'
          pages:
            - widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by ODBC'
                        name: 'Oracle: Cache Hit Ratios'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by ODBC'
                        name: 'Oracle: Physical Read\Write Rate'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by ODBC'
                        name: 'Oracle: Datafiles'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by ODBC'
                        name: 'Oracle: Processes'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graph
                  'y': '20'
                  width: '72'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by ODBC'
                        name: 'Oracle: SGA Memory Usage'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by ODBC'
                        name: 'Oracle: Sort Operations'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by ODBC'
                        name: 'Oracle: Physical Read\Write Rate, Bytes'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by ODBC'
                        name: 'Oracle: PGA'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by ODBC'
                        name: 'Oracle: Sessions'
                    - type: STRING
                      name: reference
                      value: AAAAH
      valuemaps:
        - uuid: 79af6c068ba141ba9806f4341edd9266
          name: 'Oracle Archivelog status'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Error
            - value: '2'
              newvalue: Deferred
            - value: '3'
              newvalue: Valid
        - uuid: 3afaab75342c4be186fb4f595ed62a31
          name: 'Oracle archiver state'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Stopped
            - value: '2'
              newvalue: Started
            - value: '3'
              newvalue: Failed
        - uuid: d0912db18fe54941b9345ebf869fd1a6
          name: 'Oracle DB open status'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Mounted
            - value: '2'
              newvalue: 'Read Only'
            - value: '3'
              newvalue: Read-Write
            - value: '4'
              newvalue: 'Read Only with Apply'
        - uuid: df05d594141f42ebb294cf6adca5fd6b
          name: 'Oracle DB role'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: 'Snapshot standby'
            - value: '2'
              newvalue: 'Logical standby'
            - value: '3'
              newvalue: 'Physical standby'
            - value: '4'
              newvalue: Primary
            - value: '5'
              newvalue: 'Far sync'
        - uuid: f00ca5c45ab84df788820af2642e4784
          name: 'Oracle force log status'
          mappings:
            - value: '0'
              newvalue: 'No'
            - value: '1'
              newvalue: 'Yes'
        - uuid: 97b689d7ddc04bcd9b9f92af6ba783bd
          name: 'Oracle instance role'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Primary
            - value: '2'
              newvalue: Secondary
        - uuid: 41e105c52bf045899c3c4a1cb4e16865
          name: 'Oracle instance status'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Started
            - value: '2'
              newvalue: Mounted
            - value: '3'
              newvalue: Open
            - value: '4'
              newvalue: 'Open migrate'
        - uuid: 809554f521d645ea8e8850c3b1f41579
          name: 'Oracle log mode'
          mappings:
            - value: '0'
              newvalue: NOARCHIVELOG
            - value: '1'
              newvalue: ARCHIVELOG
            - value: '2'
              newvalue: MANUAL
        - uuid: c6633e4ef9a84fa7b843529479a06158
          name: 'Oracle tablespace status'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Online
            - value: '2'
              newvalue: Offline
            - value: '3'
              newvalue: Read-Only
        - uuid: 45ad479873b84113a98fa21b21081c65
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: d670c32f007d438c9dcd32db57d2b691
      template: 'Oracle by Zabbix agent 2'
      name: 'Oracle by Zabbix agent 2'
      description: |
        Get metrics from Oracle Database using Zabbix agent 2.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Overview
        
        The template is developed to monitor a single DBMS Oracle Database instance with Zabbix agent 2.
        
        ## Supported versions
        
        Oracle Database 12c2 and newer.
        
        **Important! This integration queries the `V$ACTIVE_SESSION_HISTORY` dynamic performance view which is part of the Oracle Diagnostics Pack. Please make sure that you have the licence required for using this management pack.**
        
        ## Setup
        
        1. Set the 'URI or session name' value using either <protocol(host:port)> or named session.
        2. If you want to override parameters from Zabbix agent configuration file, set the user name, password and service name in host wizard configuration fields(Username, Password, and Service Name).
        
           User can contain sysdba, sysoper, sysasm privileges. It must be used with `as` as a separator e.g `user as sysdba`, privilege can be upper or lowercase, and must be at the end of username string.
        
        Test availability:
         ```zabbix_get -s oracle-host -k  oracle.ping["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]```
      vendor:
        name: Zabbix
        version: 7.4-1
      groups:
        - name: Templates/Databases
      items:
        - uuid: 9d24ae0f86d54b73a35d9c15d4e082cb
          name: 'Active parallel sessions'
          type: DEPENDENT
          key: oracle.active_parallel_sessions
          value_type: FLOAT
          description: 'The number of active parallel sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Active Parallel Sessions'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: sessions
        - uuid: 7e4eb79b9b674c5ba57e790fae0fb410
          name: 'Active serial sessions'
          type: DEPENDENT
          key: oracle.active_serial_sessions
          value_type: FLOAT
          description: 'The number of active serial sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Active Serial Sessions'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: sessions
        - uuid: 9763dd0b223540e4820fd3b8f3281ec3
          name: 'Average active sessions'
          type: DEPENDENT
          key: oracle.active_sessions
          value_type: FLOAT
          description: 'The average number of active sessions at a point in time that are either working or waiting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Average Active Sessions'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: sessions
        - uuid: a5533a1c354a4c8dbfec39c9b0637ba2
          name: 'Archiver state'
          type: DEPENDENT
          key: oracle.archiver_state
          description: 'The status of automatic archiving.'
          valuemap:
            name: 'Oracle archiver state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..archiver.first()
          master_item:
            key: 'oracle.instance.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: a5f5251364a44a90a66bb2096f53a48a
          name: 'Buffer cache hit ratio'
          type: DEPENDENT
          key: oracle.buffer_cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: 'The ratio of buffer cache hits ((LogRead - PhyRead)/LogRead).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Buffer Cache Hit Ratio'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 1483e7a312154438a9b09d0b696568f0
          name: 'Global cache blocks corrupted'
          type: DEPENDENT
          key: oracle.cache_blocks_corrupt
          units: Rps
          description: 'The number of blocks that encountered corruption or checksum failure during the interconnect.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Global Cache Blocks Corrupted'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 3589d4b2b9114f9cabb027f85f5349ab
          name: 'Global cache blocks lost'
          type: DEPENDENT
          key: oracle.cache_blocks_lost
          units: Rps
          description: 'The number of lost global cache blocks.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Global Cache Blocks Lost'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: cache
        - uuid: fd1ea13484984d0baffc45ea02a33a7c
          name: 'Cursor cache hit ratio'
          type: DEPENDENT
          key: oracle.cursor_cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: 'The ratio of cursor cache hits (CursorCacheHit/SoftParse).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Cursor Cache Hit Ratio'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 9fd6475d1b824c74b2b3dad1db4f494a
          name: 'Database CPU time ratio'
          type: DEPENDENT
          key: oracle.database_cpu_time_ratio
          value_type: FLOAT
          units: '%'
          description: 'The ratio calculated by dividing the total CPU (used by the database) by the Oracle time model statistic DB time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Database CPU Time Ratio'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: cpu
        - uuid: 9fc7f2e986cd4c97ad8778f06dd04822
          name: 'Database wait time ratio'
          type: DEPENDENT
          key: oracle.database_wait_time_ratio
          value_type: FLOAT
          units: '%'
          description: 'Wait time - the time that the server process spends waiting for available shared resources to be released by other server processes such as latches, locks, data buffers, etc.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Database Wait Time Ratio'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: 12efa23a53eb468ea7b0713b8f610542
          name: 'Datafiles count'
          key: 'oracle.datafiles.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          description: 'The current number of datafiles.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.datafile_num
          tags:
            - tag: component
              value: datafiles
        - uuid: cdd3d4f1baea4f2ea122e058704d43e9
          name: 'Datafiles limit'
          type: DEPENDENT
          key: oracle.db_files_limit
          description: 'The maximum allowable number of datafiles.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.db_files
          master_item:
            key: 'oracle.sys.params["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: datafiles
        - uuid: 9692f4f771844438a3f9224455c504b6
          name: 'Disk sort per second'
          type: DEPENDENT
          key: oracle.disk_sorts
          value_type: FLOAT
          units: Rps
          description: 'The number of sorts going to disk per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Disk Sort Per Sec'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: 7dc5745f2a124119b058d23195ba5058
          name: 'Enqueue timeouts per second'
          type: DEPENDENT
          key: oracle.enqueue_timeouts_rate
          value_type: FLOAT
          units: Rps
          description: 'Enqueue timeouts per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Enqueue Timeouts Per Sec'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: 1aa391bbd2484793a31dc9f0dce51b46
          name: 'Get FRA stats'
          key: 'oracle.fra.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          history: '0'
          value_type: TEXT
          description: 'Get FRA statistics.'
          tags:
            - tag: component
              value: raw
        - uuid: 5e09413cb3a14a3a87e2ead6b838ce1f
          name: 'FRA, Number of files'
          type: DEPENDENT
          key: oracle.fra_number_of_files
          description: 'The number of files in the FRA.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.number_of_files
          master_item:
            key: 'oracle.fra.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: fra
        - uuid: 68f50e7513d642f789a27dfce03ca1b8
          name: 'FRA, Number of restore points'
          type: DEPENDENT
          key: oracle.fra_restore_point
          value_type: FLOAT
          description: 'Number of restore points in the FRA.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.restore_point
          master_item:
            key: 'oracle.fra.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: fra
        - uuid: f7f16828d46a4054a30a22e955542d6a
          name: 'FRA, Space limit'
          type: DEPENDENT
          key: oracle.fra_space_limit
          units: B
          description: 'The maximum amount of disk space (in bytes) that the database can use for the Fast Recovery Area (FRA).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.space_limit
          master_item:
            key: 'oracle.fra.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: fra
        - uuid: 92d7abac10dc47a7bec1bd420a41c78c
          name: 'FRA, Space reclaimable'
          type: DEPENDENT
          key: oracle.fra_space_reclaimable
          units: B
          description: 'The total amount of disk space (in bytes) that can be created by deleting obsolete, redundant, and other low-priority files from the FRA.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.space_reclaimable
          master_item:
            key: 'oracle.fra.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: fra
        - uuid: 1e02a10018124f4db85ef9822a605b61
          name: 'FRA, Used space'
          type: DEPENDENT
          key: oracle.fra_space_used
          units: B
          description: 'The amount of disk space (in bytes) used by FRA files created in the current and all the previous FRAs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.space_used
          master_item:
            key: 'oracle.fra.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: fra
        - uuid: 887c56e1b9f1415db5def1e1f502a6ae
          name: 'FRA, Usable space in %'
          type: DEPENDENT
          key: oracle.fra_usable_pct
          value_type: FLOAT
          units: '%'
          description: 'Percentage of space usable in the FRA.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.usable_pct
          master_item:
            key: 'oracle.fra.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: fra
        - uuid: e8725c1d79e34fbc8331677fe3d4459e
          name: 'GC CR block received per second'
          type: DEPENDENT
          key: oracle.gc_cr_block_received_rate
          value_type: FLOAT
          units: Rps
          description: 'The global cache (GC) and the consistent read (CR) block received per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''GC CR Block Received Per Second'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 2c7dd0c162b742d08a2432c8bdde4ce2
          name: 'Get instance state'
          key: 'oracle.instance.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          history: '0'
          value_type: TEXT
          description: 'Gets the state of the current instance.'
          tags:
            - tag: component
              value: application
        - uuid: 021a98326c8f402693e4fba9fb3c25de
          name: 'Instance role'
          type: DEPENDENT
          key: oracle.instance.role
          description: 'Indicates whether the instance is an active instance or an inactive secondary instance.'
          valuemap:
            name: 'Oracle instance role'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.role
          master_item:
            key: 'oracle.instance.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: cd0e2c8f164443588ad19647506c0eea
          name: 'Instance hostname'
          type: DEPENDENT
          key: oracle.instance_hostname
          value_type: CHAR
          description: 'The name of the host machine.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..hostname.first()
          master_item:
            key: 'oracle.instance.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 346ef7cacf534988892970d699ef4028
              expression: 'last(/Oracle by Zabbix agent 2/oracle.instance_hostname,#1)<>last(/Oracle by Zabbix agent 2/oracle.instance_hostname,#2) and length(last(/Oracle by Zabbix agent 2/oracle.instance_hostname))>0'
              name: 'Oracle: Instance hostname has changed'
              event_name: 'Oracle: Instance hostname has changed (new hostname received: {ITEM.VALUE})'
              priority: INFO
              description: 'An Oracle Database instance hostname has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 0cc90c2554a7412eafe42c33dd1e9ede
          name: 'Instance name'
          type: DEPENDENT
          key: oracle.instance_name
          value_type: CHAR
          description: 'The name of the instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.instance
          master_item:
            key: 'oracle.instance.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: ed394860378642d5b9f220327ead6766
              expression: 'last(/Oracle by Zabbix agent 2/oracle.instance_name,#1)<>last(/Oracle by Zabbix agent 2/oracle.instance_name,#2) and length(last(/Oracle by Zabbix agent 2/oracle.instance_name))>0'
              name: 'Oracle: Instance name has changed'
              event_name: 'Oracle: Instance name has changed (new name received: {ITEM.VALUE})'
              priority: INFO
              description: 'An Oracle Database instance name has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: f51053d243ef41089b5e635fd1abb5f3
          name: 'Instance status'
          type: DEPENDENT
          key: oracle.instance_status
          description: 'The status of the instance.'
          valuemap:
            name: 'Oracle instance status'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.status
          master_item:
            key: 'oracle.instance.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: b2551269bf4541dfae378b9e48d1f5da
          name: 'Library cache hit ratio'
          type: DEPENDENT
          key: oracle.library_cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: 'The ratio of library cache hits (Hits/Pins).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Library Cache Hit Ratio'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 13a938f495ee464a8ed3f2575cd191b9
          name: 'Logons per second'
          type: DEPENDENT
          key: oracle.logons_rate
          value_type: FLOAT
          units: Rps
          description: 'The number of logon attempts.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Logons Per Sec'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: 440f42943ebc436fb75bd5d8397fe876
          name: 'Long table scans per second'
          type: DEPENDENT
          key: oracle.long_table_scans_rate
          value_type: FLOAT
          units: Rps
          description: 'The number of long table scans per second. A table is considered long if it is not cached and if its high water mark is greater than five blocks.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Long Table Scans Per Sec'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: 4769432ae04641758daabd5b27deaa01
          name: 'Memory sorts ratio'
          type: DEPENDENT
          key: oracle.memory_sorts_ratio
          value_type: FLOAT
          units: '%'
          description: 'The percentage of sorts (from `ORDER BY` clauses or index building) that are done to disk vs. in-memory.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Memory Sorts Ratio'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: 4926809f2c244b33b1a0650510a30fa4
          name: 'Get PGA stats'
          key: 'oracle.pga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          history: '0'
          value_type: TEXT
          description: 'Get PGA statistics.'
          tags:
            - tag: component
              value: raw
        - uuid: 749a1281ba84475193897a3362f6f873
          name: 'PGA, Global memory bound'
          type: DEPENDENT
          key: oracle.pga_global_bound
          units: B
          description: 'The maximum size of a work area executed in automatic mode.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''global memory bound'']'
          master_item:
            key: 'oracle.pga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: pga
        - uuid: 2b5797f046434125b65daf31121fdd81
          name: 'PGA, Aggregate target parameter'
          type: DEPENDENT
          key: oracle.pga_target
          units: B
          description: 'The current value of the `PGA_AGGREGATE_TARGET` initialization parameter. If this parameter is not set, then its value is "0" and automatic management of the PGA memory is disabled.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''aggregate PGA target parameter'']'
          master_item:
            key: 'oracle.pga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: pga
        - uuid: e96ff6a018dc4553b9ad7f2dc87f4d99
          name: 'Physical reads per second'
          type: DEPENDENT
          key: oracle.physical_reads_rate
          value_type: FLOAT
          units: Rps
          description: 'Reads per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Physical Reads Per Sec'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: disk
        - uuid: 92bf88b7b07048b785ca37d9b97cd78b
          name: 'Physical reads bytes per second'
          type: DEPENDENT
          key: oracle.physical_read_bytes_rate
          value_type: FLOAT
          units: Bps
          description: 'Read bytes per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Physical Read Bytes Per Sec'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: disk
        - uuid: b71df51181c1464486ced05c95bdc938
          name: 'Physical writes per second'
          type: DEPENDENT
          key: oracle.physical_writes_rate
          value_type: FLOAT
          units: Rps
          description: 'Writes per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Physical Writes Per Sec'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: disk
        - uuid: e34abb4139fe43ae8b27edbe6ad12c8d
          name: 'Physical writes bytes per second'
          type: DEPENDENT
          key: oracle.physical_write_bytes_rate
          value_type: FLOAT
          units: Bps
          description: 'Write bytes per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Physical Write Bytes Per Sec'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: disk
        - uuid: 7f4d8ea4912944ec8bf32edff9e3b5ae
          name: Ping
          key: 'oracle.ping["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          delay: 30s
          description: 'Test the connection to Oracle Database state.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: df6b0f5dd50848cc8c2e67947df0a5e1
              expression: 'last(/Oracle by Zabbix agent 2/oracle.ping["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"])=0'
              name: 'Oracle: Connection to database is unavailable'
              priority: DISASTER
              description: 'Connection to Oracle Database is currently unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: ce9dabcce58d408d8188fe7caa71e666
          name: 'Number of processes'
          key: 'oracle.proc.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          description: 'The current number of user processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.proc_num
          tags:
            - tag: component
              value: system
        - uuid: cdb59700d4a24fb3bea9d2b63d5d7938
          name: 'Processes limit'
          type: DEPENDENT
          key: oracle.processes_limit
          description: 'The maximum number of user processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.processes
          master_item:
            key: 'oracle.sys.params["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: system
        - uuid: 898a5325c2a2469dabb6a2356107dd66
          name: 'Redo logs available to switch'
          key: 'oracle.redolog.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          description: 'The number of inactive/unused redo logs available for log switching.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.available
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 18dba6067a254bdd99a363c3d7b9bdb2
              expression: 'max(/Oracle by Zabbix agent 2/oracle.redolog.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"],5m) < {$ORACLE.REDO.MIN.WARN}'
              name: 'Oracle: Number of REDO logs available for switching is too low'
              event_name: 'Oracle: Number of REDO logs available for switching is too low (less {$ORACLE.REDO.MIN.WARN} for 5 min)'
              priority: WARNING
              description: 'The number of inactive/unused redos available for log switching is low (risk of database downtime).'
              tags:
                - tag: scope
                  value: capacity
        - uuid: e8aca0dfd1d74d3b9b042d3ed3070e42
          name: 'Rows per sort'
          type: DEPENDENT
          key: oracle.rows_per_sort
          value_type: FLOAT
          description: 'The average number of rows per sort for all types of sorts performed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Rows Per Sort'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: 0458d6dd9bde4f2aa51319e3c23f5eae
          name: 'SQL service response time'
          type: DEPENDENT
          key: oracle.service_response_time
          value_type: FLOAT
          units: s
          description: 'The Structured Query Language (SQL) service response time expressed in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''SQL Service Response Time'']'
            - type: MULTIPLIER
              parameters:
                - '0.01'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: 41d61d167bf044fe9f0d9815b4fd27e6
          name: 'Get sessions stats'
          key: 'oracle.sessions.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{$ORACLE.SESSION.LOCK.MAX.TIME}"]'
          history: '0'
          value_type: TEXT
          description: 'Get sessions statistics. {$ORACLE.SESSION.LOCK.MAX.TIME} -- maximum seconds in the current wait condition for counting long time locked sessions. Default: 600 seconds.'
          tags:
            - tag: component
              value: raw
        - uuid: 89811a05632c478d97165f629dadd5b9
          name: 'Active background sessions'
          type: DEPENDENT
          key: oracle.session_active_background
          value_type: FLOAT
          description: 'The number of active background sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.active_background
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'oracle.sessions.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{$ORACLE.SESSION.LOCK.MAX.TIME}"]'
          tags:
            - tag: component
              value: sessions
        - uuid: a7ef5969fff545968d7c133bc67baaac
          name: 'Active user sessions'
          type: DEPENDENT
          key: oracle.session_active_user
          value_type: FLOAT
          description: 'The number of active user sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.active_user
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'oracle.sessions.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{$ORACLE.SESSION.LOCK.MAX.TIME}"]'
          tags:
            - tag: component
              value: sessions
        - uuid: d91119f30b95418bab67f929737e6bf8
          name: 'Sessions concurrency'
          type: DEPENDENT
          key: oracle.session_concurrency_rate
          value_type: FLOAT
          units: '%'
          description: 'The percentage of concurrency. Concurrency is a database behavior when different transactions request to change the same resource. In the case of modifying data transactions, it sequentially temporarily blocks the right to change the data, and the rest of the transactions wait for access. When the access to a resource is locked for a long time, the concurrency grows (like the transaction queue), often leaving an extremely negative impact on performance. A high contention value does not indicate the root cause of the problem, but is a signal to search for it.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.concurrency_rate
          master_item:
            key: 'oracle.sessions.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{$ORACLE.SESSION.LOCK.MAX.TIME}"]'
          tags:
            - tag: component
              value: sessions
          triggers:
            - uuid: ff16c7bbeaa5439f98ffe12ce7deff71
              expression: 'min(/Oracle by Zabbix agent 2/oracle.session_concurrency_rate,5m) > {$ORACLE.CONCURRENCY.MAX.WARN}'
              name: 'Oracle: Too high database concurrency'
              event_name: 'Oracle: Too high database concurrency (over {$ORACLE.CONCURRENCY.MAX.WARN}% for 5 min)'
              priority: WARNING
              description: 'The concurrency rate exceeds `{$ORACLE.CONCURRENCY.MAX.WARN}`%. A high contention value does not indicate the root cause of the problem, but is a signal to review resource consumption (determine the "heaviest" queries in the database, trace sessions, etc.) This will help find the root cause and possible optimization points both in database configuration and the logic of building queries.'
              tags:
                - tag: scope
                  value: performance
        - uuid: cfd7559ac25e4c0a837048e675f4d995
          name: 'Session count'
          type: DEPENDENT
          key: oracle.session_count
          value_type: FLOAT
          description: 'The session count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total
          master_item:
            key: 'oracle.sessions.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{$ORACLE.SESSION.LOCK.MAX.TIME}"]'
          tags:
            - tag: component
              value: sessions
        - uuid: 2222705798fd464492c6f692dd9a0392
          name: 'Inactive user sessions'
          type: DEPENDENT
          key: oracle.session_inactive_user
          value_type: FLOAT
          description: 'The number of inactive user sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.inactive_user
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: 'oracle.sessions.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{$ORACLE.SESSION.LOCK.MAX.TIME}"]'
          tags:
            - tag: component
              value: sessions
        - uuid: 381c97858785442389cd6ab74d0ee285
          name: 'Sessions limit'
          type: DEPENDENT
          key: oracle.session_limit
          description: 'The user and system sessions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.sessions
          master_item:
            key: 'oracle.sys.params["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: sessions
        - uuid: c1717acc82784151b5afc6ad08ce3145
          name: 'Sessions lock rate'
          type: DEPENDENT
          key: oracle.session_lock_rate
          value_type: FLOAT
          units: '%'
          description: 'The percentage of locked sessions. Locks are mechanisms that prevent destructive interaction between transactions accessing the same resource - either user objects, such as tables and rows or system objects not visible to users, such as shared data structures in memory and data dictionary rows.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.lock_rate
          master_item:
            key: 'oracle.sessions.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{$ORACLE.SESSION.LOCK.MAX.TIME}"]'
          tags:
            - tag: component
              value: sessions
          triggers:
            - uuid: 504e5d964de645679ce448165dadd027
              expression: 'min(/Oracle by Zabbix agent 2/oracle.session_lock_rate,5m) > {$ORACLE.SESSIONS.LOCK.MAX.WARN}'
              name: 'Oracle: Too many locked sessions'
              event_name: 'Oracle: Too many locked sessions (over {$ORACLE.SESSIONS.LOCK.MAX.WARN}% for 5 min)'
              priority: WARNING
              description: 'The number of locked sessions exceeds `{$ORACLE.SESSIONS.LOCK.MAX.WARN}`% of the running sessions.'
              tags:
                - tag: scope
                  value: performance
        - uuid: c279df21264642369d65a6c72a11698d
          name: 'Sessions locked over {$ORACLE.SESSION.LOCK.MAX.TIME}s'
          type: DEPENDENT
          key: oracle.session_long_time_locked
          value_type: FLOAT
          description: 'The count of the prolongedly locked sessions. (You can change the duration of the maximum session lock in seconds for a query using the `{$ORACLE.SESSION.LOCK.MAX.TIME}` macro. Default = 600 s).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.long_time_locked
          master_item:
            key: 'oracle.sessions.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{$ORACLE.SESSION.LOCK.MAX.TIME}"]'
          tags:
            - tag: component
              value: sessions
          triggers:
            - uuid: 5abc07cd48514a0dac90ce946ce6bc3a
              expression: 'min(/Oracle by Zabbix agent 2/oracle.session_long_time_locked,5m) > {$ORACLE.SESSION.LONG.LOCK.MAX.WARN}'
              name: 'Oracle: Too many sessions locked'
              event_name: 'Oracle: Too many sessions locked over {$ORACLE.SESSION.LOCK.MAX.TIME}s (over {$ORACLE.SESSION.LONG.LOCK.MAX.WARN} for 5 min)'
              priority: WARNING
              description: 'The number of locked sessions exceeding `{$ORACLE.SESSION.LOCK.MAX.TIME}` seconds is too high. Long-term locks can negatively affect the database performance. Therefore, if they are detected, you should first find the most difficult queries from the database point of view and then analyze possible resource leaks.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 1bafc80a94fb454785362593b8a73be3
          name: 'Get SGA stats'
          key: 'oracle.sga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          history: '0'
          value_type: TEXT
          description: 'Get SGA statistics.'
          tags:
            - tag: component
              value: raw
        - uuid: 7ad06a6ccb834c5c95f30c319a48446c
          name: 'SGA, buffer cache'
          type: DEPENDENT
          key: oracle.sga_buffer_cache
          units: B
          description: 'The size of standard block cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffer_cache
          master_item:
            key: 'oracle.sga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: cache
            - tag: component
              value: sga
        - uuid: 39dc67c29cce4742acf832949dc57760
          name: 'SGA, fixed'
          type: DEPENDENT
          key: oracle.sga_fixed
          units: B
          description: 'The fixed System Global Area (SGA) is an internal housekeeping area.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.fixed_sga
          master_item:
            key: 'oracle.sga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: sga
        - uuid: 562c02f282974020add8f98e9865fb9d
          name: 'SGA, java pool'
          type: DEPENDENT
          key: oracle.sga_java_pool
          units: B
          description: 'The memory is allocated from the Java pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.java_pool
          master_item:
            key: 'oracle.sga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: sga
        - uuid: 35e3346e273a46339e7b5d3721584d3a
          name: 'SGA, large pool'
          type: DEPENDENT
          key: oracle.sga_large_pool
          units: B
          description: 'The memory is allocated from a large pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.large_pool
          master_item:
            key: 'oracle.sga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: sga
        - uuid: 77c17fc1056745c4949b3476c3b920d4
          name: 'SGA, log buffer'
          type: DEPENDENT
          key: oracle.sga_log_buffer
          units: B
          description: 'The number of bytes allocated for the redo log buffer.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.log_buffer
          master_item:
            key: 'oracle.sga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: sga
        - uuid: b64f3cad53814e989c576d3ce51bf42d
          name: 'SGA, shared pool'
          type: DEPENDENT
          key: oracle.sga_shared_pool
          units: B
          description: 'The memory is allocated from a shared pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.shared_pool
          master_item:
            key: 'oracle.sga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: sga
        - uuid: 517c7b3bbf8d40988e6a8289319eaec9
          name: 'Shared pool free %'
          type: DEPENDENT
          key: oracle.shared_pool_free
          value_type: FLOAT
          units: '%'
          description: 'Free memory of a shared pool expressed in %.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Shared Pool Free %'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 80dbf89c86764cf09d2c5ec834e8940c
              expression: 'max(/Oracle by Zabbix agent 2/oracle.shared_pool_free,5m)<{$ORACLE.SHARED.FREE.MIN.WARN}'
              name: 'Oracle: Shared pool free is too low'
              event_name: 'Oracle: Shared pool free is too low (less {$ORACLE.SHARED.FREE.MIN.WARN}% for 5m)'
              priority: WARNING
              description: 'The free memory percent of the shared pool has been less than `{$ORACLE.SHARED.FREE.MIN.WARN}`% for the last 5 minutes.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 28c7030b02714d5ea402fe6f2a3d769a
          name: 'Total sorts per user call'
          type: DEPENDENT
          key: oracle.sorts_per_user_call
          value_type: FLOAT
          description: 'The total sorts per user call.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Total Sorts Per User Call'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: eccce1efc85d46199b3147ec586e1cd5
          name: 'Get system metrics'
          key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          delay: 0;m0-59
          history: '0'
          value_type: TEXT
          description: 'Gets the values of the system metrics.'
          tags:
            - tag: component
              value: raw
        - uuid: d59cca864e8044d89f9b4689ec712511
          name: 'Get system parameters'
          key: 'oracle.sys.params["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          history: '0'
          value_type: TEXT
          description: 'Get a set of system parameter values.'
          tags:
            - tag: component
              value: raw
        - uuid: 48f54a0324a64e80aaf22d5cd26798cd
          name: 'Temp space used'
          type: DEPENDENT
          key: oracle.temp_space_used
          value_type: FLOAT
          units: B
          description: 'Used temporary space.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''Temp Space Used'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: 1a4efb793cff4224b0ae02272be2fe85
          name: 'PGA, Total allocated'
          type: DEPENDENT
          key: oracle.total_pga_allocated
          units: B
          description: 'The current amount of the PGA memory allocated by the instance. The Oracle Database attempts to keep this number below the value of the `PGA_AGGREGATE_TARGET` initialization parameter. However, it is possible for the PGA allocated to exceed that value by a small percentage and for a short period of time when the work area workload is increasing very rapidly or when `PGA_AGGREGATE_TARGET` is set to a small value.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''total PGA allocated'']'
          master_item:
            key: 'oracle.pga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: pga
        - uuid: 264b73d153694b52a47ac0219a8de66c
          name: 'PGA, Total freeable'
          type: DEPENDENT
          key: oracle.total_pga_freeable
          units: B
          description: 'The number of bytes of the PGA memory in all processes that could be freed back to the OS.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''total freeable PGA memory'']'
          master_item:
            key: 'oracle.pga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: pga
        - uuid: 3f3083748a4f42998b135b1b4f88d11a
          name: 'PGA, Total inuse'
          type: DEPENDENT
          key: oracle.total_pga_used
          units: B
          description: 'The amount of Program Global Area (PGA) memory currently consumed by work areas. This number can be used to determine how much memory is consumed by other consumers of the PGA memory (for example, PL/SQL or Java).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''total PGA inuse'']'
          master_item:
            key: 'oracle.pga.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: memory
            - tag: component
              value: pga
        - uuid: 4f1a9efea8594486b226307a52e35474
          name: Uptime
          type: DEPENDENT
          key: oracle.uptime
          trends: '0'
          units: s
          description: 'The Oracle instance uptime expressed in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.uptime
          master_item:
            key: 'oracle.instance.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: bcdaf519783f453e81d7064207f8bd30
              expression: 'nodata(/Oracle by Zabbix agent 2/oracle.uptime,30m)=1'
              name: 'Oracle: Failed to fetch info data'
              event_name: 'Oracle: Failed to fetch info data (or no data for 30m)'
              priority: INFO
              description: 'Zabbix has not received any data for the items for the last 5 minutes. The database might be unavailable for connecting.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 5eae478e85834eee91b94680d529dcdb
              expression: 'last(/Oracle by Zabbix agent 2/oracle.uptime)<10m'
              name: 'Oracle: Host has been restarted'
              event_name: 'Oracle: {HOST.NAME} has been restarted (uptime < 10m)'
              priority: INFO
              description: 'Uptime is less than 10 minutes.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 73ff311f3d5c4e93b5919f5633fc09f9
          name: 'User''s expire password'
          key: 'oracle.user.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          value_type: FLOAT
          units: days
          description: 'The number of days before the Zabbix account password expires.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.exp_passwd_days_before
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 5eaa700c3bb74399ad2d26c382397415
              expression: 'last(/Oracle by Zabbix agent 2/oracle.user.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"])  < {$ORACLE.EXPIRE.PASSWORD.MIN.WARN}'
              name: 'Oracle: Zabbix account will expire soon'
              event_name: 'Oracle: Zabbix account will expire soon (under {$ORACLE.EXPIRE.PASSWORD.MIN.WARN} days)'
              priority: WARNING
              description: 'The password for the Zabbix user in the database expires soon.'
              tags:
                - tag: scope
                  value: notice
        - uuid: cec9a53d637e42c79e2a838588ceeaca
          name: 'User rollbacks per second'
          type: DEPENDENT
          key: oracle.user_rollbacks_rate
          value_type: FLOAT
          units: Rps
          description: 'The number of times that users manually issued the `ROLLBACK` statement or an error occurred during the users'' transactions.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''User Rollbacks Per Sec'']'
          master_item:
            key: 'oracle.sys.metrics["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          tags:
            - tag: component
              value: application
        - uuid: 04c0b90a0a7c4d6a95f51d006a65a530
          name: Version
          key: 'oracle.version["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          delay: 15m
          value_type: CHAR
          description: 'The Oracle Server version.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 4a68bcb6149c4c839e263c949343add8
              expression: 'last(/Oracle by Zabbix agent 2/oracle.version["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"],#1)<>last(/Oracle by Zabbix agent 2/oracle.version["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"],#2) and length(last(/Oracle by Zabbix agent 2/oracle.version["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]))>0'
              name: 'Oracle: Version has changed'
              event_name: 'Oracle: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              description: 'The Oracle Database version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
      discovery_rules:
        - uuid: e2f1ce8c037f4efa9bdb98166d344be6
          name: 'Archive log discovery'
          key: 'oracle.archive.discovery["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          delay: 1h
          description: 'Destinations of the log archive.'
          item_prototypes:
            - uuid: 1ad93880e4314d68b9e1aa4e00f03b6e
              name: 'Archivelog ''{#DEST_NAME}'': Get archive log info'
              key: 'oracle.archive.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DEST_NAME}"]'
              delay: 5m
              history: '0'
              value_type: TEXT
              description: 'Gets the archive log statistics.'
              tags:
                - tag: component
                  value: archive-log
                - tag: component
                  value: raw
            - uuid: 46ae0ac79493430a94ac50f79dc053ba
              name: 'Archivelog ''{#DEST_NAME}'': Error'
              type: DEPENDENT
              key: 'oracle.archivelog_error["{#DEST_NAME}"]'
              value_type: TEXT
              description: 'Displays the error message.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#DEST_NAME}''].error.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oracle.archive.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DEST_NAME}"]'
              tags:
                - tag: component
                  value: archive-log
                - tag: destination
                  value: '{#DEST_NAME}'
            - uuid: ce76a8ece06f4a17bfaf08b4351346d5
              name: 'Archivelog ''{#DEST_NAME}'': Last sequence'
              type: DEPENDENT
              key: 'oracle.archivelog_log_sequence["{#DEST_NAME}"]'
              description: 'Identifies the sequence number of the last archived redo log to be archived.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#DEST_NAME}''].log_sequence.first()'
              master_item:
                key: 'oracle.archive.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DEST_NAME}"]'
              tags:
                - tag: component
                  value: archive-log
                - tag: destination
                  value: '{#DEST_NAME}'
            - uuid: a411a4e1c8ca4ea2a1ece92075cd0325
              name: 'Archivelog ''{#DEST_NAME}'': Status'
              type: DEPENDENT
              key: 'oracle.archivelog_log_status["{#DEST_NAME}"]'
              description: |
                Identifies the current status of the destination where:
                1 - VALID;
                2 - DEFERRED;
                3 - ERROR;
                0 - UNKNOWN.
              valuemap:
                name: 'Oracle Archivelog status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#DEST_NAME}''].status.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oracle.archive.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DEST_NAME}"]'
              tags:
                - tag: component
                  value: archive-log
                - tag: destination
                  value: '{#DEST_NAME}'
              trigger_prototypes:
                - uuid: e2d393c0ff2f420097e19890bcbe215c
                  expression: 'last(/Oracle by Zabbix agent 2/oracle.archivelog_log_status["{#DEST_NAME}"])<2'
                  name: 'Oracle: Archivelog ''{#DEST_NAME}'': Log Archive is not valid'
                  priority: HIGH
                  description: |
                    The trigger will launch if the archive log destination is not in one of these states:
                    2 - DEFERRED;
                    3 - VALID.
                  tags:
                    - tag: scope
                      value: availability
        - uuid: 59840e68757644afbcf6ec49a6f5e95d
          name: 'Database discovery'
          key: 'oracle.db.discovery["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          delay: 1h
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DBNAME}'
                value: '{$ORACLE.DBNAME.MATCHES}'
              - macro: '{#DBNAME}'
                value: '{$ORACLE.DBNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Scanning databases in the database management system (DBMS).'
          item_prototypes:
            - uuid: 1bad65e85d8b482d9cd83b1d202f8d8c
              name: 'Database ''{#DBNAME}'': Get CDB and No-CDB info'
              key: 'oracle.cdb.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Gets the information about the CDB and non-CDB database on an instance.'
              tags:
                - tag: component
                  value: cdb
                - tag: component
                  value: raw
            - uuid: d9d1575b767b46e0aefe65a270f2d01b
              name: 'Database ''{#DBNAME}'': Force logging'
              type: DEPENDENT
              key: 'oracle.db_force_logging["{#DBNAME}"]'
              description: 'Indicates whether the database is under force logging mode (`YES`/`NO`).'
              valuemap:
                name: 'Oracle force log status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..{#DBNAME}.force_logging.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'oracle.cdb.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
                - tag: type
                  value: '{#TYPE}'
            - uuid: a499423d6e8d44f2bc11beceb30c5fc1
              name: 'Database ''{#DBNAME}'': Log mode'
              type: DEPENDENT
              key: 'oracle.db_log_mode["{#DBNAME}"]'
              description: |
                The archive log mode where:
                0 - NOARCHIVELOG;
                1 - ARCHIVELOG;
                2 - MANUAL.
              valuemap:
                name: 'Oracle log mode'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..{#DBNAME}.log_mode.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'oracle.cdb.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
                - tag: type
                  value: '{#TYPE}'
            - uuid: 0b0cfebb30aa4d21b8ff91f887fdffde
              name: 'Database ''{#DBNAME}'': Open status'
              type: DEPENDENT
              key: 'oracle.db_open_mode["{#DBNAME}"]'
              description: |
                1 - MOUNTED;
                2 - READ WRITE;
                3 - READ ONLY;
                4 - READ ONLY WITH APPLY (a physical standby database is open in real-time query mode).
              valuemap:
                name: 'Oracle DB open status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..{#DBNAME}.open_mode.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'oracle.cdb.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
                - tag: type
                  value: '{#TYPE}'
              trigger_prototypes:
                - uuid: fb642c2cfeb142409c67a7755d1047cc
                  expression: 'last(/Oracle by Zabbix agent 2/oracle.db_open_mode["{#DBNAME}"],#1)<>last(/Oracle by Zabbix agent 2/oracle.db_open_mode["{#DBNAME}"],#2)'
                  name: 'Oracle: Database ''{#DBNAME}'': Open status has changed'
                  event_name: 'Oracle: Database ''{#DBNAME}'': Open status has changed (new value received: {ITEM.VALUE})'
                  priority: INFO
                  description: 'The Oracle Database open status has changed. Acknowledge to close the problem manually.'
                  manual_close: 'YES'
                  dependencies:
                    - name: 'Oracle: Database ''{#DBNAME}'': Open status in mount mode'
                      expression: 'last(/Oracle by Zabbix agent 2/oracle.db_open_mode["{#DBNAME}"])=1'
                  tags:
                    - tag: scope
                      value: notice
                - uuid: ef1c57d8f7d34c02bf0b7347d9fddf54
                  expression: 'last(/Oracle by Zabbix agent 2/oracle.db_open_mode["{#DBNAME}"])=1'
                  name: 'Oracle: Database ''{#DBNAME}'': Open status in mount mode'
                  priority: WARNING
                  description: 'The Oracle Database is in a mounted state.'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 560b010dcdfc445cbd4e266b88b60e24
              name: 'Database ''{#DBNAME}'': Role'
              type: DEPENDENT
              key: 'oracle.db_role["{#DBNAME}"]'
              description: |
                The current role of the database where:
                1 - SNAPSHOT STANDBY;
                2 - LOGICAL STANDBY;
                3 - PHYSICAL STANDBY;
                4 - PRIMARY;
                5 - FAR SYNC.
              valuemap:
                name: 'Oracle DB role'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..{#DBNAME}.role.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'oracle.cdb.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
                - tag: type
                  value: '{#TYPE}'
              trigger_prototypes:
                - uuid: 24fef0b751fd4d089eced3c210954b4f
                  expression: 'last(/Oracle by Zabbix agent 2/oracle.db_role["{#DBNAME}"],#1)<>last(/Oracle by Zabbix agent 2/oracle.db_role["{#DBNAME}"],#2)'
                  name: 'Oracle: Database ''{#DBNAME}'': Role has changed'
                  event_name: 'Oracle: Database ''{#DBNAME}'': Role has changed (new value received: {ITEM.VALUE})'
                  priority: INFO
                  description: 'The Oracle Database role has changed. Acknowledge to close the problem manually.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: notice
          trigger_prototypes:
            - uuid: 049473f763d84700b62abf5c914390fe
              expression: 'last(/Oracle by Zabbix agent 2/oracle.db_force_logging["{#DBNAME}"]) = 0 and last(/Oracle by Zabbix agent 2/oracle.db_log_mode["{#DBNAME}"]) = 1'
              name: 'Oracle: Database ''{#DBNAME}'': Force logging is deactivated for DB with active Archivelog'
              priority: WARNING
              description: 'Force logging mode is a very important metric for databases in `ARCHIVELOG`. This feature allows to forcibly write all the transactions to the redo log.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 8d31eea973a7408abf0eb25ca7ba70c6
          name: 'ASM disk groups discovery'
          key: 'oracle.diskgroups.discovery["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          delay: 1h
          description: 'The ASM disk groups.'
          item_prototypes:
            - uuid: 8b4e5c9385d04a39b2187e093ffca213
              name: 'ASM ''{#DGNAME}'': Free size'
              type: DEPENDENT
              key: 'oracle.asm_free_size["{#DGNAME}"]'
              units: B
              description: 'The free size of the ASM disk group.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#DGNAME}''].free_bytes.first()'
              master_item:
                key: 'oracle.diskgroups.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DGNAME}"]'
              tags:
                - tag: component
                  value: asm
                - tag: disk-group
                  value: '{#DGNAME}'
            - uuid: b80f69f44dd24eae82a301dbefb0c60f
              name: 'ASM ''{#DGNAME}'': Total size'
              type: DEPENDENT
              key: 'oracle.asm_total_size["{#DGNAME}"]'
              units: B
              description: 'The total size of the ASM disk group.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#DGNAME}''].total_bytes.first()'
              master_item:
                key: 'oracle.diskgroups.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DGNAME}"]'
              tags:
                - tag: component
                  value: asm
                - tag: disk-group
                  value: '{#DGNAME}'
            - uuid: e2a0ac73040f401bb05ff88140f6665b
              name: 'ASM ''{#DGNAME}'': Used size, percent'
              type: DEPENDENT
              key: 'oracle.asm_used_pct["{#DGNAME}"]'
              value_type: FLOAT
              units: '%'
              description: 'Usage of the ASM disk group expressed in %.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#DGNAME}''].used_pct.first()'
              master_item:
                key: 'oracle.diskgroups.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DGNAME}"]'
              tags:
                - tag: component
                  value: asm
                - tag: disk-group
                  value: '{#DGNAME}'
              trigger_prototypes:
                - uuid: b8aa1b00e2574e35bf71554cabfffcfc
                  expression: 'min(/Oracle by Zabbix agent 2/oracle.asm_used_pct["{#DGNAME}"],5m)>{$ORACLE.ASM.USED.PCT.MAX.HIGH}'
                  name: 'Oracle: ASM ''{#DGNAME}'': Disk group usage is too high'
                  event_name: 'Oracle: ASM ''{#DGNAME}'': Disk group usage is too high (over {$ORACLE.ASM.USED.PCT.MAX.HIGH}% for 5m)'
                  priority: HIGH
                  description: 'The usage of the ASM disk group expressed in % exceeds `{$ORACLE.ASM.USED.PCT.MAX.HIGH}`.'
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: af6ff1d099524209b2806b1257e9a8e3
                  expression: 'min(/Oracle by Zabbix agent 2/oracle.asm_used_pct["{#DGNAME}"],5m)>{$ORACLE.ASM.USED.PCT.MAX.WARN}'
                  name: 'Oracle: ASM ''{#DGNAME}'': Disk group usage is too high'
                  event_name: 'Oracle: ASM ''{#DGNAME}'': Disk group usage is too high (over {$ORACLE.ASM.USED.PCT.MAX.WARN}% for 5m)'
                  priority: WARNING
                  description: 'The usage of the ASM disk group expressed in % exceeds `{$ORACLE.ASM.USED.PCT.MAX.WARN}`.'
                  dependencies:
                    - name: 'Oracle: ASM ''{#DGNAME}'': Disk group usage is too high'
                      expression: 'min(/Oracle by Zabbix agent 2/oracle.asm_used_pct["{#DGNAME}"],5m)>{$ORACLE.ASM.USED.PCT.MAX.HIGH}'
                  tags:
                    - tag: scope
                      value: capacity
            - uuid: cb703b07fc514ce5aedc561896bcd53f
              name: 'ASM ''{#DGNAME}'': Get ASM stats'
              key: 'oracle.diskgroups.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#DGNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Gets the ASM disk group statistics.'
              tags:
                - tag: component
                  value: asm
                - tag: component
                  value: raw
          graph_prototypes:
            - uuid: f42e49e6743f4b08b5bdc3ab284b26f3
              name: 'ASM ''{#DGNAME}'': ASM disk group ''{#DGNAME}'''
              graph_items:
                - color: 199C0D
                  item:
                    host: 'Oracle by Zabbix agent 2'
                    key: 'oracle.asm_free_size["{#DGNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'Oracle by Zabbix agent 2'
                    key: 'oracle.asm_total_size["{#DGNAME}"]'
        - uuid: 479a56fe538f46c094cc4b595d070776
          name: 'PDB discovery'
          key: 'oracle.pdb.discovery["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          delay: 1h
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DBNAME}'
                value: '{$ORACLE.DBNAME.MATCHES}'
              - macro: '{#DBNAME}'
                value: '{$ORACLE.DBNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Scanning a pluggable database (PDB) in DBMS.'
          item_prototypes:
            - uuid: ca4452418d2641bd87fa75e946c2bf98
              name: 'Database ''{#DBNAME}'': Get PDB info'
              key: 'oracle.pdb.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#CON_ID}"]'
              history: '0'
              value_type: TEXT
              description: 'Gets the information about the PDB database on an instance.'
              tags:
                - tag: component
                  value: pdb
                - tag: component
                  value: raw
            - uuid: c52e96105cea45cea1b18201b325ba53
              name: 'Database ''{#DBNAME}'': Open status'
              type: DEPENDENT
              key: 'oracle.pdb_open_mode["{#CON_ID}"]'
              description: |
                1 - MOUNTED;
                2 - READ WRITE;
                3 - READ ONLY;
                4 - READ ONLY WITH APPLY (a physical standby database is open in real-time query mode).
              valuemap:
                name: 'Oracle DB open status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..{#DBNAME}.open_mode.first()'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 15m
              master_item:
                key: 'oracle.pdb.info["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#CON_ID}"]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DBNAME}'
                - tag: type
                  value: pdb
              trigger_prototypes:
                - uuid: 61f48e1d858f4e95a603b32ee1c409dc
                  expression: 'last(/Oracle by Zabbix agent 2/oracle.pdb_open_mode["{#CON_ID}"],#1)<>last(/Oracle by Zabbix agent 2/oracle.pdb_open_mode["{#CON_ID}"],#2)'
                  name: 'Oracle: Database ''{#DBNAME}'': Open status has changed'
                  event_name: 'Oracle: Database ''{#DBNAME}'': Open status has changed (new value received: {ITEM.VALUE})'
                  priority: INFO
                  description: 'The Oracle Database open status has changed. Acknowledge to close the problem manually.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: notice
                - uuid: a6921cc3b42843dcb5624b3bb172f996
                  expression: 'last(/Oracle by Zabbix agent 2/oracle.pdb_open_mode["{#CON_ID}"])=1'
                  name: 'Oracle: Database ''{#DBNAME}'': Open status in mount mode'
                  priority: WARNING
                  description: 'The Oracle Database is in a mounted state.'
                  tags:
                    - tag: scope
                      value: notice
        - uuid: 46ee5f42a15b43a58f7ef0ce5e3638d3
          name: 'Tablespace discovery'
          key: 'oracle.ts.discovery["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
          delay: 1h
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CON_NAME}'
                value: '{$ORACLE.TABLESPACE.CONTAINER.MATCHES}'
              - macro: '{#CON_NAME}'
                value: '{$ORACLE.TABLESPACE.CONTAINER.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#TABLESPACE}'
                value: '{$ORACLE.TABLESPACE.NAME.MATCHES}'
              - macro: '{#TABLESPACE}'
                value: '{$ORACLE.TABLESPACE.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Scanning tablespaces in DBMS.'
          item_prototypes:
            - uuid: 14a26a84cfe947089843ed93cd7707c8
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace allocated, bytes'
              type: DEPENDENT
              key: 'oracle.tbs_alloc_bytes["{#CON_ID}","{#TABLESPACE}"]'
              units: B
              description: 'Currently allocated bytes for the tablespace (sum of the current size of datafiles).'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#TABLESPACE}''].file_bytes.first()'
              master_item:
                key: 'oracle.ts.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#TABLESPACE}","{#CONTENTS}","{#CON_ID}"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
            - uuid: d7263b6da6c04c7798909a8448f526ab
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace free, bytes'
              type: DEPENDENT
              key: 'oracle.tbs_free_bytes["{#CON_ID}","{#TABLESPACE}"]'
              units: B
              description: 'Free bytes of the allocated space.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#TABLESPACE}''].free_bytes.first()'
              master_item:
                key: 'oracle.ts.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#TABLESPACE}","{#CONTENTS}","{#CON_ID}"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
            - uuid: d2d919d303b244829c797245e08c2fe5
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace MAX size, bytes'
              type: DEPENDENT
              key: 'oracle.tbs_max_bytes["{#CON_ID}","{#TABLESPACE}"]'
              units: B
              description: 'The maximum size of the tablespace.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#TABLESPACE}''].max_bytes.first()'
              master_item:
                key: 'oracle.ts.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#TABLESPACE}","{#CONTENTS}","{#CON_ID}"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
            - uuid: de6892ac5ca4499db01dd02c0444aafc
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Open status'
              type: DEPENDENT
              key: 'oracle.tbs_status["{#CON_ID}","{#TABLESPACE}"]'
              description: |
                The tablespace status where:
                1 - ONLINE;
                2 - OFFLINE;
                3 - READ ONLY.
              valuemap:
                name: 'Oracle tablespace status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#TABLESPACE}''].status.first()'
              master_item:
                key: 'oracle.ts.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#TABLESPACE}","{#CONTENTS}","{#CON_ID}"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
              trigger_prototypes:
                - uuid: 832f908ca3b84a3c9a030b5d33b96016
                  expression: 'last(/Oracle by Zabbix agent 2/oracle.tbs_status["{#CON_ID}","{#TABLESPACE}"])=2'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace is OFFLINE'
                  priority: WARNING
                  description: 'The tablespace is in the offline state.'
                  tags:
                    - tag: scope
                      value: availability
                - uuid: 2e84836974b340b5b916eed08e1fcdf4
                  expression: 'last(/Oracle by Zabbix agent 2/oracle.tbs_status["{#CON_ID}","{#TABLESPACE}"],#1)<>last(/Oracle by Zabbix agent 2/oracle.tbs_status["{#CON_ID}","{#TABLESPACE}"],#2)'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace status has changed'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace status has changed (new value received: {ITEM.VALUE})'
                  priority: INFO
                  description: 'Oracle tablespace status has changed. Acknowledge to close the problem manually.'
                  manual_close: 'YES'
                  dependencies:
                    - name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace is OFFLINE'
                      expression: 'last(/Oracle by Zabbix agent 2/oracle.tbs_status["{#CON_ID}","{#TABLESPACE}"])=2'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: ab56fee407e143db912dffcf24fb0106
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace used, bytes'
              type: DEPENDENT
              key: 'oracle.tbs_used_bytes["{#CON_ID}","{#TABLESPACE}"]'
              units: B
              description: 'Currently used bytes for the tablespace (current size of datafiles minus the free space).'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#TABLESPACE}''].used_bytes.first()'
              master_item:
                key: 'oracle.ts.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#TABLESPACE}","{#CONTENTS}","{#CON_ID}"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
            - uuid: 358615a3e372462e9cec05df1df22743
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage, percent'
              type: DEPENDENT
              key: 'oracle.tbs_used_file_pct["{#CON_ID}","{#TABLESPACE}"]'
              value_type: FLOAT
              units: '%'
              description: 'Used bytes/allocated bytes*100.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#TABLESPACE}''].used_file_pct.first()'
              master_item:
                key: 'oracle.ts.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#TABLESPACE}","{#CONTENTS}","{#CON_ID}"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
              trigger_prototypes:
                - uuid: bbc86236064348ee9150dfdd07623061
                  expression: 'min(/Oracle by Zabbix agent 2/oracle.tbs_used_file_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.MAX.HIGH}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage is too high (over {$ORACLE.TBS.USED.PCT.MAX.HIGH}% for 5m).'
                  priority: HIGH
                  description: 'The usage of the tablespace `{#TABLESPACE}` exceeds `{$ORACLE.TBS.USED.PCT.MAX.HIGH}`%'
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: ba298d35aaaa4386b4f03914dcf1cb27
                  expression: 'min(/Oracle by Zabbix agent 2/oracle.tbs_used_file_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.MAX.WARN}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage is too high (over {$ORACLE.TBS.USED.PCT.MAX.WARN}% for 5m).'
                  priority: WARNING
                  description: 'The usage of the tablespace `{#TABLESPACE}` exceeds `{$ORACLE.TBS.USED.PCT.MAX.WARN}`%'
                  dependencies:
                    - name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage is too high'
                      expression: 'min(/Oracle by Zabbix agent 2/oracle.tbs_used_file_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.MAX.HIGH}'
                  tags:
                    - tag: scope
                      value: capacity
            - uuid: 93f6abb8363e4ee2ad2801090cf006b0
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage from MAX, percent'
              type: DEPENDENT
              key: 'oracle.tbs_used_from_max_pct["{#CON_ID}","{#TABLESPACE}"]'
              value_type: FLOAT
              units: '%'
              description: 'Used bytes/max bytes*100.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#TABLESPACE}''].used_from_max_pct.first()'
              master_item:
                key: 'oracle.ts.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#TABLESPACE}","{#CONTENTS}","{#CON_ID}"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
              trigger_prototypes:
                - uuid: dd246e51d0b343f0b18b18dc802dfbc2
                  expression: 'min(/Oracle by Zabbix agent 2/oracle.tbs_used_from_max_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.FROM.MAX.WARN}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace usage from MAX is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization from MAX is too high (over {$ORACLE.TBS.USED.PCT.FROM.MAX.WARN}% for 5m).'
                  priority: WARNING
                  description: 'The usage of the tablespace `{#TABLESPACE}` from MAX exceeds `{$ORACLE.TBS.USED.PCT.FROM.MAX.WARN}`%'
                  dependencies:
                    - name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization from MAX is too high'
                      expression: 'min(/Oracle by Zabbix agent 2/oracle.tbs_used_from_max_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.FROM.MAX.HIGH}'
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: a82c07893e04440ea9c0e5e7f8f79602
                  expression: 'min(/Oracle by Zabbix agent 2/oracle.tbs_used_from_max_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.USED.PCT.FROM.MAX.HIGH}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization from MAX is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization from MAX is too high (over {$ORACLE.TBS.USED.PCT.FROM.MAX.HIGH}% for 5m).'
                  priority: HIGH
                  description: 'The usage of the tablespace `{#TABLESPACE}` from MAX exceeds `{$ORACLE.TBS.USED.PCT.FROM.MAX.HIGH}`%'
                  tags:
                    - tag: scope
                      value: capacity
            - uuid: 5d6293b33a46488c88a75dc898bf7059
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace allocated, percent'
              type: DEPENDENT
              key: 'oracle.tbs_used_pct["{#CON_ID}","{#TABLESPACE}"]'
              value_type: FLOAT
              units: '%'
              description: 'Allocated bytes/max bytes*100.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[''{#TABLESPACE}''].used_pct_max.first()'
              master_item:
                key: 'oracle.ts.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#TABLESPACE}","{#CONTENTS}","{#CON_ID}"]'
              tags:
                - tag: component
                  value: tablespaces
                - tag: contents
                  value: '{#CONTENTS}'
                - tag: database
                  value: '{#CON_NAME}'
                - tag: tablespace
                  value: '{#TABLESPACE}'
              trigger_prototypes:
                - uuid: 451108a2251848ea8719378d5c0abb42
                  expression: 'min(/Oracle by Zabbix agent 2/oracle.tbs_used_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.UTIL.PCT.MAX.HIGH}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization is too high (over {$ORACLE.TBS.UTIL.PCT.MAX.HIGH}% for 5m).'
                  priority: HIGH
                  description: 'The utilization of the tablespace `{#TABLESPACE}` exceeds `{$ORACLE.TBS.UTIL.PCT.MAX.HIGH}`%'
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: 2530cb03fb4e4e728396834f0db89466
                  expression: 'min(/Oracle by Zabbix agent 2/oracle.tbs_used_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.UTIL.PCT.MAX.WARN}'
                  name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization is too high'
                  event_name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization is too high (over {$ORACLE.TBS.UTIL.PCT.MAX.WARN}% for 5m).'
                  priority: WARNING
                  description: 'The utilization of the tablespace `{#TABLESPACE}` exceeds `{$ORACLE.TBS.UTIL.PCT.MAX.WARN}`%'
                  dependencies:
                    - name: 'Oracle: ''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace utilization is too high'
                      expression: 'min(/Oracle by Zabbix agent 2/oracle.tbs_used_pct["{#CON_ID}","{#TABLESPACE}"],5m)>{$ORACLE.TBS.UTIL.PCT.MAX.HIGH}'
                  tags:
                    - tag: scope
                      value: capacity
            - uuid: 97ac4acedcde465b8d004a8ac476dd99
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Get tablespaces stats'
              key: 'oracle.ts.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}","{#TABLESPACE}","{#CONTENTS}","{#CON_ID}"]'
              history: '0'
              value_type: TEXT
              description: 'Gets the statistics of the tablespace.'
              tags:
                - tag: component
                  value: raw
                - tag: component
                  value: tablespaces
          graph_prototypes:
            - uuid: 4b20cce21abb453f9aab0dbce75ff060
              name: '''{#CON_NAME}'' TBS ''{#TABLESPACE}'': Tablespace ''{#TABLESPACE}'''
              graph_items:
                - color: 199C0D
                  item:
                    host: 'Oracle by Zabbix agent 2'
                    key: 'oracle.tbs_alloc_bytes["{#CON_ID}","{#TABLESPACE}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'Oracle by Zabbix agent 2'
                    key: 'oracle.tbs_max_bytes["{#CON_ID}","{#TABLESPACE}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'Oracle by Zabbix agent 2'
                    key: 'oracle.tbs_used_bytes["{#CON_ID}","{#TABLESPACE}"]'
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: oracle
      macros:
        - macro: '{$ORACLE.ASM.USED.PCT.MAX.HIGH}'
          value: '95'
          description: 'The maximum percentage of used space in the Automatic Storage Management (ASM) disk group for the High trigger expression.'
          config:
            type: TEXT
            priority: '29'
            section_name: Thresholds
            label: 'High threshold for used space in the ASM'
            description: 'Maximum percentage of used space in the Automatic Storage Management (ASM) disk group for the High trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.ASM.USED.PCT.MAX.WARN}'
          value: '90'
          description: 'The maximum percentage of used space in the Automatic Storage Management (ASM) disk group for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '28'
            section_name: Thresholds
            label: 'Warning threshold for used space in the ASM'
            description: 'Maximum percentage of used space in the Automatic Storage Management (ASM) disk group for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.CONCURRENCY.MAX.WARN}'
          value: '80'
          description: 'The maximum percentage of session concurrency for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '24'
            section_name: Thresholds
            label: 'Warning threshold for session concurrency'
            description: 'Maximum percentage of session concurrency for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.CONNSTRING}'
          description: 'Oracle URI or a session name.'
          config:
            type: TEXT
            priority: '3'
            label: 'URI or session name'
            description: 'Oracle database URI or a session name.'
            required: 'YES'
        - macro: '{$ORACLE.DB.FILE.MAX.WARN}'
          value: '80'
          description: 'The maximum percentage of used database files for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '19'
            section_name: Thresholds
            label: 'Warning threshold for used database files'
            description: 'Maximum percentage of used database files for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.DBNAME.MATCHES}'
          value: '.*'
          description: 'Used in database discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '5'
            section_name: Filters
            label: 'Include database filter'
            description: 'Regex string to include discovered database.'
        - macro: '{$ORACLE.DBNAME.NOT_MATCHES}'
          value: PDB\$SEED
          description: 'Used in database discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '6'
            section_name: Filters
            label: 'Exclude database filter'
            description: 'Regex string to exclude discovered database.'
        - macro: '{$ORACLE.EXPIRE.PASSWORD.MIN.WARN}'
          value: '7'
          description: 'The number of days before the password expires for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '27'
            section_name: Thresholds
            label: 'Warning threshold in days before the password expires'
            description: 'Number of days before the password expires for the Warning trigger expression.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Oracle user''s password.'
          config:
            type: TEXT
            priority: '2'
            label: Password
            description: 'Oracle database password.'
            required: 'YES'
        - macro: '{$ORACLE.PGA.USE.MAX.WARN}'
          value: '90'
          description: 'Alert threshold for the maximum percentage of the Program Global Area (PGA) usage for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '20'
            section_name: Thresholds
            label: 'Warning threshold for PGA usage'
            description: 'Alert threshold for the maximum percentage of the Program Global Area (PGA) usage for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.PROCESSES.MAX.WARN}'
          value: '80'
          description: 'Alert threshold for the maximum percentage of active processes for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '17'
            section_name: Thresholds
            label: 'Warning threshold for active processes'
            description: 'Alert threshold for the maximum percentage of active processes for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.REDO.MIN.WARN}'
          value: '3'
          description: 'Alert threshold for the minimum number of redo logs for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '25'
            section_name: Thresholds
            label: 'Warning threshold for minimum number of redo logs'
            description: 'Alert threshold for the minimum number of redo logs for the Warning trigger expression.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.SERVICE}'
          value: ORA
          description: 'Oracle Service Name.'
          config:
            type: TEXT
            priority: '4'
            label: 'Service Name'
            description: 'Oracle Service Name.'
        - macro: '{$ORACLE.SESSION.LOCK.MAX.TIME}'
          value: '600'
          description: 'The maximum duration of the session lock in seconds to count the session as a prolongedly locked query.'
          config:
            type: TEXT
            priority: '22'
            section_name: Thresholds
            label: 'Duration of the session lock'
            description: 'Maximum duration of the session lock in seconds to count the session as a prolongedly locked query.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.SESSION.LONG.LOCK.MAX.WARN}'
          value: '3'
          description: 'Alert threshold for the maximum number of the prolongedly locked sessions for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '23'
            section_name: Thresholds
            label: 'Warning threshold for prolongedly locked sessions'
            description: 'Alert threshold for the maximum number of the prolongedly locked sessions for the Warning trigger expression.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.SESSIONS.LOCK.MAX.WARN}'
          value: '20'
          description: 'Alert threshold for the maximum percentage of locked sessions for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '21'
            section_name: Thresholds
            label: 'Warning threshold for locked sessions'
            description: 'Alert threshold for the maximum percentage of locked sessions for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.SESSIONS.MAX.WARN}'
          value: '80'
          description: 'Alert threshold for the maximum percentage of active sessions for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '18'
            section_name: Thresholds
            label: 'Warning threshold for active sessions'
            description: 'Alert threshold for the maximum percentage of active sessions for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.SHARED.FREE.MIN.WARN}'
          value: '5'
          description: 'Alert threshold for the minimum percentage of free shared pool for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '26'
            section_name: Thresholds
            label: 'Warning threshold for free shared pool'
            description: 'Alert threshold for the minimum percentage of free shared pool for the Warning trigger expression.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TABLESPACE.CONTAINER.MATCHES}'
          value: '.*'
          description: 'Used in tablespace discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '7'
            section_name: Filters
            label: 'Include tablespace container filter'
            description: 'Regex string to include discovered tablespace container.'
        - macro: '{$ORACLE.TABLESPACE.CONTAINER.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Used in tablespace discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '8'
            section_name: Filters
            label: 'Exclude tablespace container filter'
            description: 'Regex string to exclude discovered tablespace container.'
        - macro: '{$ORACLE.TABLESPACE.NAME.MATCHES}'
          value: '.*'
          description: 'Used in tablespace discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '9'
            section_name: Filters
            label: 'Include tablespace name filter'
            description: 'Regex string to include discovered tablespace.'
        - macro: '{$ORACLE.TABLESPACE.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Used in tablespace discovery. It can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '10'
            section_name: Filters
            label: 'Exclude tablespace name filter'
            description: 'Regex string to exclude discovered tablespace.'
        - macro: '{$ORACLE.TBS.USED.PCT.FROM.MAX.HIGH}'
          value: '95'
          description: 'High severity alert threshold for the maximum percentage of tablespace usage (used bytes/max bytes) for the High trigger expression.'
          config:
            type: TEXT
            priority: '12'
            section_name: Thresholds
            label: 'High severity alert threshold for from maximum tablespace size'
            description: 'High severity alert threshold for the maximum percentage of tablespace usage (used bytes/max bytes) for the High trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TBS.USED.PCT.FROM.MAX.WARN}'
          value: '90'
          description: 'Warning severity alert threshold for the maximum percentage of tablespace usage from maximum tablespace size (used bytes/max bytes) for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'Warning severity alert threshold for from maximum tablespace size'
            description: 'Warning severity alert threshold for the maximum percentage of tablespace usage from maximum tablespace size (used bytes/max bytes) for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TBS.USED.PCT.MAX.HIGH}'
          value: '95'
          description: 'High severity alert threshold for the maximum percentage of tablespace usage (used bytes/allocated bytes) for the High trigger expression.'
          config:
            type: TEXT
            priority: '14'
            section_name: Thresholds
            label: 'High severity alert threshold for the maximum percentage of tablespace usage'
            description: 'High severity alert threshold for the maximum percentage of tablespace usage (used bytes/allocated bytes) for the High trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TBS.USED.PCT.MAX.WARN}'
          value: '90'
          description: 'Warning severity alert threshold for the maximum percentage of tablespace usage (used bytes/allocated bytes) for the Warning trigger expression.'
          config:
            type: TEXT
            priority: '13'
            section_name: Thresholds
            label: 'Warning severity alert threshold for the maximum percentage of tablespace usage'
            description: 'Warning severity alert threshold for the maximum percentage of tablespace usage (used bytes/allocated bytes) for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TBS.UTIL.PCT.MAX.HIGH}'
          value: '90'
          description: 'High severity alert threshold for the maximum percentage of tablespace utilization (allocated bytes/max bytes) for the High trigger expression.'
          config:
            type: TEXT
            priority: '16'
            section_name: Thresholds
            label: 'High severity alert threshold for tablespace utilization'
            description: 'High severity alert threshold for the maximum percentage of tablespace utilization (allocated bytes/max bytes) for the High trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.TBS.UTIL.PCT.MAX.WARN}'
          value: '80'
          description: 'Warning severity alert threshold for the maximum percentage of tablespace utilization (allocated bytes/max bytes) for the High trigger expression.'
          config:
            type: TEXT
            priority: '15'
            section_name: Thresholds
            label: 'Warning severity alert threshold for tablespace utilization'
            description: 'Warning severity alert threshold for the maximum percentage of tablespace utilization (allocated bytes/max bytes) for the Warning trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$ORACLE.USER}'
          description: 'Oracle username.'
          config:
            type: TEXT
            priority: '1'
            label: Username
            description: 'Oracle database username.'
            required: 'YES'
      dashboards:
        - uuid: 60f2fa6384884e09a7c475e7c04b1515
          name: 'Oracle Performance'
          pages:
            - widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by Zabbix agent 2'
                        name: 'Oracle: Cache Hit Ratios'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by Zabbix agent 2'
                        name: 'Oracle: Physical Read\Write Rate'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by Zabbix agent 2'
                        name: 'Oracle: Datafiles'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by Zabbix agent 2'
                        name: 'Oracle: Processes'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graph
                  'y': '20'
                  width: '72'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by Zabbix agent 2'
                        name: 'Oracle: SGA Memory Usage'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by Zabbix agent 2'
                        name: 'Oracle: Sort Operations'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by Zabbix agent 2'
                        name: 'Oracle: Physical Read\Write Rate, Bytes'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by Zabbix agent 2'
                        name: 'Oracle: PGA'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle by Zabbix agent 2'
                        name: 'Oracle: Sessions'
                    - type: STRING
                      name: reference
                      value: AAAAH
      valuemaps:
        - uuid: 5a90da8dd6124159a7f82a7a996f0a53
          name: 'Oracle Archivelog status'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Error
            - value: '2'
              newvalue: Deferred
            - value: '3'
              newvalue: Valid
        - uuid: f39e64058fef423bb858ba45834a3455
          name: 'Oracle archiver state'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Stopped
            - value: '2'
              newvalue: Started
            - value: '3'
              newvalue: Failed
        - uuid: 015a0c94ba2644c6aa343d3f792a4072
          name: 'Oracle DB open status'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Mounted
            - value: '2'
              newvalue: 'Read Only'
            - value: '3'
              newvalue: Read-Write
            - value: '4'
              newvalue: 'Read Only with Apply'
        - uuid: afade10cda4e453982355342ba9d8d9f
          name: 'Oracle DB role'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: 'Snapshot standby'
            - value: '2'
              newvalue: 'Logical standby'
            - value: '3'
              newvalue: 'Physical standby'
            - value: '4'
              newvalue: Primary
            - value: '5'
              newvalue: 'Far sync'
        - uuid: 1d9f4a44f2f94a799768f147cb712331
          name: 'Oracle force log status'
          mappings:
            - value: '0'
              newvalue: 'No'
            - value: '1'
              newvalue: 'Yes'
        - uuid: 53d97b73db8449959420e03114d345c3
          name: 'Oracle instance role'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Primary
            - value: '2'
              newvalue: Secondary
        - uuid: 4893318c780f47719e12e839c9a846c2
          name: 'Oracle instance status'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Started
            - value: '2'
              newvalue: Mounted
            - value: '3'
              newvalue: Open
            - value: '4'
              newvalue: 'Open migrate'
        - uuid: 910dd4a87f75434289fa2e345778d18d
          name: 'Oracle log mode'
          mappings:
            - value: '0'
              newvalue: NOARCHIVELOG
            - value: '1'
              newvalue: ARCHIVELOG
            - value: '2'
              newvalue: MANUAL
        - uuid: f14ed94cf12740a19e221ddaa4855c54
          name: 'Oracle tablespace status'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Online
            - value: '2'
              newvalue: Offline
            - value: '3'
              newvalue: Read-Only
        - uuid: 31c489581d8b4246942c663b88fbaf9f
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: e0a7c3e725c445228b03116dc6114fe9
      template: 'PostgreSQL by ODBC'
      name: 'PostgreSQL by ODBC'
      description: |
        This template is designed for the effortless deployment of PostgreSQL monitoring by Zabbix via ODBC and doesn't require any external scripts.
        
        Setup:
        
        1. Create the PostgreSQL user for monitoring (`<password>` at your discretion) and inherit permissions from the default role `pg_monitor`:
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
        GRANT pg_monitor TO zbx_monitor;
        
        2. Edit the `pg_hba.conf` configuration file to allow TCP connections for the user `zbx_monitor`. You can check the PostgreSQL documentation for examples (https://www.postgresql.org/docs/current/auth-pg-hba-conf.html).
        
        3. Install the PostgreSQL ODBC driver.
        
        4. Set up the connection string with the `{$PG.CONNSTRING.ODBC}` macro. The minimum required parameters are:
        - `Driver=` - set the name of the driver which will be used for monitoring (from the `odbcinst.ini` file) or specify the path to the driver file (for example `/usr/lib64/psqlodbcw.so`);
        - `Servername=` - set the host name or IP address of the PostgreSQL instance;
        - `Port=` - adjust the port number if needed.
        
        If you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, you can also specify encryption parameters here.
        
        It is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation (https://www.postgresql.org/docs/current/ssl-tcp.html) for details.
        
        For example, to enable required encryption in transport mode without identity checks, the connection string could look like this (replace `<instanceip>` with the address of the PostgreSQL instance):
        Servername=<instanceip>;Port=5432;Driver=/usr/lib64/psqlodbcw.so;SSLmode=require
        
        5. Set the password that you specified in step 1 in the macro `{$PG.PASSWORD}`.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384190-%C2%A0discussion-thread-for-official-zabbix-template-db-postgresql
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        1. Create the PostgreSQL user for monitoring (`<password>` at your discretion) and inherit permissions from the default role `pg_monitor`:
        
        ```sql
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
        GRANT pg_monitor TO zbx_monitor;
        ```
        
        2. Edit the `pg_hba.conf` configuration file to allow TCP connections for the user `zbx_monitor`. For example, you could add one of the following rows to allow local connections from the same host:
        
        ```bash
        # TYPE  DATABASE        USER            ADDRESS                 METHOD
          host       all        zbx_monitor     localhost               trust
          host       all        zbx_monitor     127.0.0.1/32            md5
          host       all        zbx_monitor     ::1/128                 scram-sha-256
        ```
        
        For more information please read the PostgreSQL documentation `https://www.postgresql.org/docs/current/auth-pg-hba-conf.html`.
        
        3. Install the PostgreSQL ODBC driver. Check the [`Zabbix documentation`](https://www.zabbix.com/documentation/7.4/manual/config/items/itemtypes/odbc_checks/) for details about ODBC checks and [`recommended parameters page`](https://www.zabbix.com/documentation/7.4/manual/config/items/itemtypes/odbc_checks/unixodbc_postgresql).
        
        4. Set up the connection string in the `PostgreSQL connection string` host wizard configuration field. The minimum required parameters are:
        
        - `Driver=` - set the name of the driver which will be used for monitoring (from the `odbcinst.ini` file) or specify the path to the driver file (for example `/usr/lib64/psqlodbcw.so`);
        - `Servername=` - set the host name or IP address of the PostgreSQL instance;
        - `Port=` - adjust the port number if needed.
        
        **Note:** if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, you can also specify encryption parameters here.
        
        It is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the [`PostgreSQL documentation`](https://www.postgresql.org/docs/current/ssl-tcp.html) for details.
        
        For example, to enable required encryption in transport mode without identity checks, the connection string could look like this (replace `<instanceip>` with the address of the PostgreSQL instance):
        
        ```
        Servername=<instanceip>;Port=5432;Driver=/usr/lib64/psqlodbcw.so;SSLmode=require
        ```
        
        5. Set the password that you specified in step 1 in the `PostgreSQL user password` field.
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Databases
      items:
        - uuid: 9440208c49134347809eff39109c644f
          name: 'Get archive'
          type: ODBC
          key: 'db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          history: '0'
          value_type: TEXT
          params: |
            WITH values AS (
              SELECT
                4096/(ceil(pg_settings.setting::numeric/1024/1024))::int AS segment_parts_count,
                setting::bigint AS segment_size,
                ('x' || substring(pg_stat_archiver.last_archived_wal from 9 for 8))::bit(32)::int AS last_wal_div,
                ('x' || substring(pg_stat_archiver.last_archived_wal from 17 for 8))::bit(32)::int AS last_wal_mod,
                CASE WHEN pg_is_in_recovery() THEN NULL 
                  ELSE ('x' || substring(pg_walfile_name(pg_current_wal_lsn()) from 9 for 8))::bit(32)::int END AS current_wal_div,
                CASE WHEN pg_is_in_recovery() THEN NULL 
                  ELSE ('x' || substring(pg_walfile_name(pg_current_wal_lsn()) from 17 for 8))::bit(32)::int END AS current_wal_mod
              FROM pg_settings, pg_stat_archiver
              WHERE pg_settings.name = 'wal_segment_size')
            SELECT json_build_object(
              'archived_count', (SELECT archived_count FROM pg_stat_archiver),
              'failed_count', (SELECT failed_count FROM pg_stat_archiver),
              'count_files', (SELECT greatest(coalesce((segment_parts_count - last_wal_mod) + ((current_wal_div - last_wal_div - 1) * segment_parts_count) + current_wal_mod - 1, 0), 0) FROM values),
              'size_files', (SELECT greatest(coalesce(((segment_parts_count - last_wal_mod) + ((current_wal_div - last_wal_div - 1) * segment_parts_count) + current_wal_mod - 1) * segment_size, 0), 0) FROM values)
            ) AS result
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Collect archive status metrics.'
          tags:
            - tag: component
              value: raw
        - uuid: dd79edeb2d65420fb58d587e411c440f
          name: 'Count of autovacuum workers'
          type: ODBC
          key: 'db.odbc.select[pgsql.autovacuum.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          value_type: FLOAT
          params: |
            SELECT count(*)
              FROM pg_catalog.pg_stat_activity
                WHERE backend_type = 'autovacuum worker'
                  AND state <> 'idle'
                  AND pid <> pg_catalog.pg_backend_pid()
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Number of autovacuum workers.'
          tags:
            - tag: component
              value: system
        - uuid: 1d267b6aed064d03b4f464b27c1e897e
          name: 'Get connections sum'
          type: ODBC
          key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT row_to_json(T)
              FROM (
                SELECT
                  sum(CASE WHEN state = 'active' THEN 1 ELSE 0 END) AS active,
                  sum(CASE WHEN state = 'idle' THEN 1 ELSE 0 END) AS idle,
                  sum(CASE WHEN state = 'idle in transaction' THEN 1 ELSE 0 END) AS idle_in_transaction,
                  sum(CASE WHEN state = 'idle in transaction (aborted)' THEN 1 ELSE 0 END) AS idle_in_transaction_aborted,
                  sum(CASE WHEN state = 'fastpath function call' THEN 1 ELSE 0 END) AS fastpath_function_call,
                  sum(CASE WHEN state = 'disabled' THEN 1 ELSE 0 END) AS disabled,
                  count(*) AS total,
                  count(*)*100/(SELECT current_setting('max_connections')::int) AS total_pct,
                  sum(CASE WHEN wait_event IS NOT NULL THEN 1 ELSE 0 END) AS waiting,
                  (SELECT count(*) FROM pg_prepared_xacts) AS prepared
                FROM pg_stat_activity WHERE datid IS NOT NULL AND state IS NOT NULL) T
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: |
            Collect all metrics from pg_stat_activity:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: 0f93764d56574a288467ad16dce11a17
          name: 'Get dbstat'
          type: ODBC
          key: 'db.odbc.select[pgsql.dbstat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT json_object_agg(coalesce (datname,'null'), row_to_json(T)) FROM (
              SELECT datname,
                numbackends AS numbackends,
                xact_commit AS xact_commit,
                xact_rollback AS xact_rollback,
                blks_read AS blks_read,
                blks_hit AS blks_hit,
                tup_returned AS tup_returned,
                tup_fetched AS tup_fetched,
                tup_inserted AS tup_inserted,
                tup_updated AS tup_updated,
                tup_deleted AS tup_deleted,
                conflicts AS conflicts,
                temp_files AS temp_files,
                temp_bytes AS temp_bytes,
                deadlocks AS deadlocks,
                blk_read_time AS blk_read_time,
                blk_write_time AS blk_write_time
              FROM pg_catalog.pg_stat_database WHERE datname IS NOT NULL) T;
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: |
            Collect all metrics from pg_stat_database per database:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: 6ea1a17fad8b4ef3aba8b49a0922a77d
          name: 'Get dbstat sum'
          type: ODBC
          key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT row_to_json(T) FROM (
              SELECT sum(numbackends) AS numbackends,
                sum(xact_commit) AS xact_commit,
                sum(xact_rollback) AS xact_rollback,
                sum(blks_read) AS blks_read,
                sum(blks_hit) AS blks_hit,
                sum(tup_returned) AS tup_returned,
                sum(tup_fetched) AS tup_fetched,
                sum(tup_inserted) AS tup_inserted,
                sum(tup_updated) AS tup_updated,
                sum(tup_deleted) AS tup_deleted,
                sum(conflicts) AS conflicts,
                sum(temp_files) AS temp_files,
                sum(temp_bytes) AS temp_bytes,
                sum(deadlocks) AS deadlocks,
                sum(blk_read_time) AS blk_read_time,
                sum(blk_write_time) AS blk_write_time
              FROM pg_stat_database) T
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: |
            Collect all metrics from pg_stat_database as sums for all databases:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: efa015e294684fdeb711a0fde1256cf9
          name: 'Get locks'
          type: ODBC
          key: 'db.odbc.select[pgsql.locks,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          history: '0'
          value_type: TEXT
          params: |
            WITH T AS
              (SELECT db.datname dbname,
                  lower(replace(Q.mode, 'Lock', '')) AS MODE,
                  coalesce(T.qty, 0) val
              FROM pg_database db
              JOIN (
                  VALUES ('AccessShareLock') ,('RowShareLock') ,('RowExclusiveLock') ,('ShareUpdateExclusiveLock') ,('ShareLock') ,('ShareRowExclusiveLock') ,('ExclusiveLock') ,('AccessExclusiveLock')) Q(MODE) ON TRUE NATURAL
              LEFT JOIN
                (SELECT datname,
                  MODE,
                  count(MODE) qty
                FROM pg_locks lc
                RIGHT JOIN pg_database db ON db.oid = lc.database
                GROUP BY 1, 2) T
              WHERE NOT db.datistemplate
              ORDER BY 1, 2)
            SELECT json_object_agg(dbname, row_to_json(T2))
            FROM
              (SELECT dbname,
                  sum(val) AS total,
                  sum(CASE
                      WHEN MODE = 'accessexclusive' THEN val
                    END) AS accessexclusive,
                  sum(CASE
                      WHEN MODE = 'accessshare' THEN val
                    END) AS accessshare,
                  sum(CASE
                      WHEN MODE = 'exclusive' THEN val
                    END) AS EXCLUSIVE,
                  sum(CASE
                      WHEN MODE = 'rowexclusive' THEN val
                    END) AS rowexclusive,
                  sum(CASE
                      WHEN MODE = 'rowshare' THEN val
                    END) AS rowshare,
                  sum(CASE
                      WHEN MODE = 'share' THEN val
                    END) AS SHARE,
                  sum(CASE
                      WHEN MODE = 'sharerowexclusive' THEN val
                    END) AS sharerowexclusive,
                  sum(CASE
                      WHEN MODE = 'shareupdateexclusive' THEN val
                    END) AS shareupdateexclusive
              FROM T
              GROUP BY dbname) T2
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: |
            Collect all metrics from pg_locks per database:
            https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES
          tags:
            - tag: component
              value: raw
        - uuid: 266a9b5c1e604d97ac5a74ccdb598c97
          name: 'Age of oldest xid'
          type: ODBC
          key: 'db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          value_type: FLOAT
          params: |
            SELECT greatest(max(age(backend_xmin)), max(age(backend_xid)))
              FROM pg_catalog.pg_stat_activity
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Age of oldest xid.'
          tags:
            - tag: component
              value: transactions
          triggers:
            - uuid: 4d32971898d441fb94d5f029649dddfa
              expression: 'last(/PostgreSQL by ODBC/db.odbc.select[pgsql.oldest.xid,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]) > 18000000'
              name: 'PostgreSQL: Oldest xid is too big'
              priority: AVERAGE
              tags:
                - tag: scope
                  value: availability
        - uuid: 3c16a3c2db7641c2b6958649d7b4809e
          name: Ping
          type: ODBC
          key: 'db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          params: 'SELECT 1'
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: 758e569b51954fcf82c7cb3fa391c882
              expression: 'last(/PostgreSQL by ODBC/db.odbc.select[pgsql.ping,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"])=0'
              name: 'PostgreSQL: Service is down'
              priority: HIGH
              description: 'Last test of a connection was unsuccessful.'
              tags:
                - tag: scope
                  value: availability
        - uuid: ee6b3f64e07d4acd875dbd83dccd51d0
          name: 'Get queries'
          type: ODBC
          key: 'db.odbc.select[pgsql.queries,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          history: '0'
          value_type: TEXT
          params: |
            WITH T AS
              (SELECT db.datname,
                coalesce(T.query_time_max, 0) query_time_max,
                coalesce(T.tx_time_max, 0) tx_time_max,
                coalesce(T.mro_time_max, 0) mro_time_max,
                coalesce(T.query_time_sum, 0) query_time_sum,
                coalesce(T.tx_time_sum, 0) tx_time_sum,
                coalesce(T.mro_time_sum, 0) mro_time_sum,
                coalesce(T.query_slow_count, 0) query_slow_count,
                coalesce(T.tx_slow_count, 0) tx_slow_count,
                coalesce(T.mro_slow_count, 0) mro_slow_count
              FROM pg_database db NATURAL
              LEFT JOIN (
                SELECT datname,
                  extract(epoch FROM now())::integer ts,
                  coalesce(max(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle', 'idle in transaction', 'idle in transaction (aborted)') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) query_time_max,
                  coalesce(max(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) tx_time_max,
                  coalesce(max(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle') AND query ~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) mro_time_max,
                  coalesce(sum(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle', 'idle in transaction', 'idle in transaction (aborted)') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) query_time_sum,
                  coalesce(sum(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) tx_time_sum,
                  coalesce(sum(extract('epoch' FROM (clock_timestamp() - query_start))::integer * (state NOT IN ('idle') AND query ~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) mro_time_sum,
            
                  coalesce(sum((extract('epoch' FROM (clock_timestamp() - query_start)) > {$PG.QUERY_ETIME.MAX.WARN})::integer * (state NOT IN ('idle', 'idle in transaction', 'idle in transaction (aborted)') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) query_slow_count,
                  coalesce(sum((extract('epoch' FROM (clock_timestamp() - query_start)) > {$PG.QUERY_ETIME.MAX.WARN})::integer * (state NOT IN ('idle') AND query !~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) tx_slow_count,
                  coalesce(sum((extract('epoch' FROM (clock_timestamp() - query_start)) > {$PG.QUERY_ETIME.MAX.WARN})::integer * (state NOT IN ('idle') AND query ~* E'^(\\s*(--[^\\n]*\\n|/\\*.*\\*/|\\n))*(autovacuum|VACUUM|ANALYZE|REINDEX|CLUSTER|CREATE|ALTER|TRUNCATE|DROP)')::integer), 0) mro_slow_count
                FROM pg_stat_activity
                WHERE pid <> pg_backend_pid()
                GROUP BY 1) T
              WHERE NOT db.datistemplate )
            SELECT json_object_agg(datname, row_to_json(T))
            FROM T
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Collect all metrics by query execution time.'
          tags:
            - tag: component
              value: raw
        - uuid: d156db3cb35049a88179060583961156
          name: 'Replication: Standby count'
          type: ODBC
          key: 'db.odbc.select[pgsql.replication.count,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          params: 'SELECT count(*) FROM pg_stat_replication'
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Number of standby servers.'
          tags:
            - tag: component
              value: replication
        - uuid: 669d87ebf9324d6eaa26c3cb44efc850
          name: 'Replication: Lag in bytes'
          type: ODBC
          key: 'db.odbc.select[pgsql.replication.lag.b,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          units: B
          params: |
            SELECT
              CASE
                WHEN NOT pg_is_in_recovery() OR pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn() THEN 0
                  ELSE COALESCE(EXTRACT(EPOCH FROM now() - pg_last_xact_replay_timestamp())::integer, 0)
                END AS lag
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Replication lag with master, in bytes.'
          tags:
            - tag: component
              value: replication
        - uuid: bb87b83d35784d3ea5be2263fa3722b0
          name: 'Replication: Lag in seconds'
          type: ODBC
          key: 'db.odbc.select[pgsql.replication.lag.sec,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          units: s
          params: |
            SELECT
              CASE
                WHEN NOT pg_is_in_recovery() OR pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn() THEN 0
                  ELSE COALESCE(EXTRACT(EPOCH FROM now() - pg_last_xact_replay_timestamp())::integer, 0)
                END AS lag
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Replication lag with master, in seconds.'
          tags:
            - tag: component
              value: replication
        - uuid: 3f2b5c02a6be40d4837205f68aaacabb
          name: 'Get replication'
          type: ODBC
          key: 'db.odbc.select[pgsql.replication.process,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          history: '0'
          value_type: TEXT
          params: |
            SELECT json_object_agg(application_name, row_to_json(T))
              FROM (
                SELECT
                  application_name,
                  EXTRACT(epoch FROM COALESCE(flush_lag,'0'::interval)) AS flush_lag,
                  EXTRACT(epoch FROM COALESCE(replay_lag,'0'::interval)) AS replay_lag,
                  EXTRACT(epoch FROM COALESCE(write_lag, '0'::interval)) AS write_lag
                FROM pg_stat_replication
              ) T
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Collect metrics from the pg_stat_replication, which contains information about the WAL sender process, showing statistics about replication to that sender''s connected standby server.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          tags:
            - tag: component
              value: raw
        - uuid: f8205cdd902a4a688b5bcb7f65d8e41d
          name: 'Replication: Recovery role'
          type: ODBC
          key: 'db.odbc.select[pgsql.replication.recovery_role,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          params: 'SELECT pg_is_in_recovery()::int'
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode.'
          valuemap:
            name: 'PostgreSQL recovery role'
          tags:
            - tag: component
              value: replication
        - uuid: 6cc8c748f6174d3dba9aa9b39570b006
          name: 'Replication: Status'
          type: ODBC
          key: 'db.odbc.select[pgsql.replication.status,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          params: |
            SELECT
              CASE
                WHEN NOT pg_is_in_recovery() THEN 2
                ELSE (SELECT count(*) FROM pg_stat_wal_receiver)
              END AS repl_status
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode.'
          valuemap:
            name: 'PostgreSQL replication status'
          tags:
            - tag: component
              value: replication
        - uuid: 817c494132044fff88ea4c9fcaacb60a
          name: Uptime
          type: ODBC
          key: 'db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          value_type: FLOAT
          units: uptime
          params: 'SELECT date_part(''epoch'', now() - pg_postmaster_start_time())'
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Time since the server started.'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 22077f0b0ee54becb43ef9ab808c3e43
              expression: 'last(/PostgreSQL by ODBC/db.odbc.select[pgsql.uptime,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]) < 10m'
              name: 'PostgreSQL: Service has been restarted'
              event_name: 'PostgreSQL: Service has been restarted (uptime < 10m)'
              priority: AVERAGE
              description: 'PostgreSQL uptime is less than 10 minutes.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 4bfb0c1697f043d9acf640b84cc8d945
          name: Version
          type: ODBC
          key: 'db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          delay: 15m
          value_type: CHAR
          params: 'SELECT version()'
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'PostgreSQL version.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: fd409b64f83943edaf43845a12bf8ace
              expression: 'last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],#1)<>last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"],#2) and length(last(/PostgreSQL by ODBC/db.odbc.select[pgsql.version,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]))>0'
              name: 'PostgreSQL: Version has changed'
              event_name: 'PostgreSQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              tags:
                - tag: scope
                  value: notice
        - uuid: 0b76450dd17d47a1829f51960dcb1374
          name: 'Version (numeric)'
          type: ODBC
          key: 'db.odbc.select[pgsql.version.num,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          delay: 15m
          trends: '0'
          params: 'SELECT current_setting(''server_version_num'')'
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Reports the version number of the server as an integer.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          tags:
            - tag: component
              value: application
        - uuid: 8af13c6154744e9596a0f96dfbf09d8b
          name: 'Get WAL'
          type: ODBC
          key: 'db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          delay: 5m
          history: '0'
          value_type: TEXT
          params: |
            SELECT row_to_json(T)
              FROM (
                SELECT
                  CASE
                    WHEN pg_is_in_recovery() THEN 0
                    ELSE pg_wal_lsn_diff(pg_current_wal_lsn(),'0/00000000')
                  END AS WRITE,
                  CASE 
                    WHEN NOT pg_is_in_recovery() THEN 0
                    ELSE pg_wal_lsn_diff(pg_last_wal_receive_lsn(),'0/00000000')
                  END AS RECEIVE,
                  count(*)
                  FROM pg_ls_waldir() AS COUNT
              ) T
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          description: 'Collect write-ahead log (WAL) metrics.'
          tags:
            - tag: component
              value: raw
        - uuid: d69d40f3e7064f668b0bf150ff73aafc
          name: 'Archive: Count of archived files'
          type: DEPENDENT
          key: pgsql.archive.count_archived_files
          value_type: FLOAT
          description: 'Count of archived files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.archived_count
          master_item:
            key: 'db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: archive
        - uuid: c1cc1236cf0c412a84e7d1ff3fec14e5
          name: 'Archive: Count of files in archive_status need to archive'
          type: DEPENDENT
          key: pgsql.archive.count_files_to_archive
          value_type: FLOAT
          description: 'Count of files to archive.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.count_files
          master_item:
            key: 'db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: archive
        - uuid: 1ea44a48aaf042debc078ad920dd4f02
          name: 'Archive: Count of failed attempts to archive files'
          type: DEPENDENT
          key: pgsql.archive.failed_trying_to_archive
          value_type: FLOAT
          description: 'Count of failed attempts to archive files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.failed_count
          master_item:
            key: 'db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: archive
        - uuid: 13f563e6152a482fb48415d81f916af2
          name: 'Archive: Size of files need to archive'
          type: DEPENDENT
          key: pgsql.archive.size_files_to_archive
          value_type: FLOAT
          description: 'Size of files to archive.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.size_files
          master_item:
            key: 'db.odbc.select[pgsql.archive,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: archive
        - uuid: 9b8faf03797f4dccb9573b664805478a
          name: 'Bgwriter LLD'
          type: DEPENDENT
          key: pgsql.bgwriter.lld
          history: '0'
          value_type: CHAR
          description: 'LLD data for "bgwriter" metrics discovery.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var version_num = parseInt(value, 10),
                  	result = [{
                  		'{#BELOW_V17}': 'false',
                  		'{#SINGLETON}': ''
                  	}];
                  
                  if (version_num < 170000) {
                  	result[0]['{#BELOW_V17}'] = 'true';
                  }
                  
                  return JSON.stringify(result);
          master_item:
            key: 'db.odbc.select[pgsql.version.num,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: raw
        - uuid: 6444043a810b4b2f89740c1c794a47c0
          name: 'Cache hit ratio, %'
          type: CALCULATED
          key: pgsql.cache.hit
          value_type: FLOAT
          units: '%'
          params: 'last(//pgsql.dbstat.sum.blks_hit.rate) * 100 / (last(//pgsql.dbstat.sum.blks_hit.rate) + last(//pgsql.dbstat.sum.blks_read.rate))'
          description: 'Cache hit ratio.'
          tags:
            - tag: component
              value: cache
        - uuid: 5e3e5b6a244c4dfdacc7167196e28d7d
          name: 'Connections sum: Active'
          type: DEPENDENT
          key: pgsql.connections.sum.active
          description: 'Total number of connections executing a query.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.active
          master_item:
            key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 2dd753d41b5e4c4098fef4fe5ac51060
          name: 'Connections sum: Disabled'
          type: DEPENDENT
          key: pgsql.connections.sum.disabled
          description: 'Total number of disabled connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.disabled
          master_item:
            key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 6d379fe1fe424ed68dea03a90da81da0
          name: 'Connections sum: Fastpath function call'
          type: DEPENDENT
          key: pgsql.connections.sum.fastpath_function_call
          description: 'Total number of connections executing a fast-path function.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.fastpath_function_call
          master_item:
            key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 8b777c5628c4462580f1ae70790fb584
          name: 'Connections sum: Idle'
          type: DEPENDENT
          key: pgsql.connections.sum.idle
          description: 'Total number of connections waiting for a new client command.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle
          master_item:
            key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 7851bc86735e46a48fd5c82d83ef066a
          name: 'Connections sum: Idle in transaction'
          type: DEPENDENT
          key: pgsql.connections.sum.idle_in_transaction
          description: 'Total number of connections in a transaction state but not executing a query.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle_in_transaction
          master_item:
            key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 9267653f21b445beaacd3de3e55ad4ae
          name: 'Connections sum: Idle in transaction (aborted)'
          type: DEPENDENT
          key: pgsql.connections.sum.idle_in_transaction_aborted
          description: 'Total number of connections in a transaction state but not executing a query, and where one of the statements in the transaction caused an error.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle_in_transaction_aborted
          master_item:
            key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 512e90360d4d4b95aa23014181697afe
          name: 'Connections sum: Prepared'
          type: DEPENDENT
          key: pgsql.connections.sum.prepared
          description: |
            Total number of prepared transactions:
            https://www.postgresql.org/docs/current/sql-prepare-transaction.html
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.prepared
          master_item:
            key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 4d092ed405e2410f9e1a4cdb31249fe0
          name: 'Connections sum: Total'
          type: DEPENDENT
          key: pgsql.connections.sum.total
          description: 'Total number of connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total
          master_item:
            key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 2b2ca7abb85b4ae1992cbfc6902206a1
          name: 'Connections sum: Total, %'
          type: DEPENDENT
          key: pgsql.connections.sum.total_pct
          units: '%'
          description: 'Total number of connections, in percentage.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total_pct
          master_item:
            key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: 3b6662191c3b46ac930af02797a7162b
              expression: 'min(/PostgreSQL by ODBC/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN}'
              name: 'PostgreSQL: Total number of connections is too high'
              event_name: 'PostgreSQL: Total number of connections is too high (over {$PG.CONN_TOTAL_PCT.MAX.WARN}% in 5m)'
              priority: AVERAGE
              description: 'Total number of current connections exceeds the limit of {$PG.CONN_TOTAL_PCT.MAX.WARN}% out of the maximum number of concurrent connections to the database server (the "max_connections" setting).'
              tags:
                - tag: scope
                  value: performance
        - uuid: 7f525a9b9b6a494db660649388b8cb21
          name: 'Connections sum: Waiting'
          type: DEPENDENT
          key: pgsql.connections.sum.waiting
          description: |
            Total number of waiting connections:
            https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.waiting
          master_item:
            key: 'db.odbc.select[pgsql.connections.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 6cb6aaa39f494f13b792ea0d1570f0af
          name: 'Dbstat: Hit blocks read per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blks_hit.rate
          value_type: FLOAT
          description: 'Number of times per second disk blocks were found already in the buffer cache.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blks_hit
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 8861dbcc607b481e9f7ca6b3081530a8
          name: 'Dbstat: Disk blocks read per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blks_read.rate
          value_type: FLOAT
          description: 'Number of disk blocks read per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blks_read
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: storage
        - uuid: a8a7afddbe7546068e3d629747d73848
          name: 'Dbstat: Blocks read time'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blk_read_time
          value_type: FLOAT
          units: s
          description: 'Time spent reading data file blocks by backends.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blk_read_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: storage
        - uuid: 40b1da9a55cf4312a66dffa9031b9b15
          name: 'Dbstat: Blocks write time'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blk_write_time
          value_type: FLOAT
          units: s
          description: 'Time spent writing data file blocks by backends.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blk_write_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: storage
        - uuid: ef6c8945243f41e88a08d93e66eec666
          name: 'Dbstat: Conflicts per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.conflicts.rate
          value_type: FLOAT
          description: 'Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.conflicts
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 5adcf2ce06984da2b0b0600d88e88451
          name: 'Dbstat: Deadlocks per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.deadlocks.rate
          value_type: FLOAT
          description: 'Number of deadlocks detected per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.deadlocks
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: deadlocks
        - uuid: 26da7e85356644cdbe4d9efd20e43dd2
          name: 'Dbstat: Backends connected'
          type: DEPENDENT
          key: pgsql.dbstat.sum.numbackends
          description: 'Number of connected backends.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.numbackends
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: backends
        - uuid: 4c18ecf383154136ad68d5d938fc83d7
          name: 'Dbstat: Number temp bytes per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.temp_bytes.rate
          value_type: FLOAT
          units: b
          description: 'Total amount of data written per second to temporary files by queries.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.temp_bytes
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: storage
        - uuid: 0c7ad16e40e3454aaad27a6fe4b5e62d
          name: 'Dbstat: Number temp files per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.temp_files.rate
          value_type: FLOAT
          description: 'Number of temporary files created by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.temp_files
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: storage
        - uuid: e3cd2d8ec2b8454f949c69bb00e0db57
          name: 'Dbstat: Rows deleted per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_deleted.rate
          value_type: FLOAT
          description: 'Number of rows deleted by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_deleted
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 9f09f94dcd6744e8b6a53167b1835a16
          name: 'Dbstat: Rows fetched per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_fetched.rate
          value_type: FLOAT
          description: 'Number of rows fetched by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_fetched
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 916291299e624959993f8a585da6c9c0
          name: 'Dbstat: Rows inserted per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_inserted.rate
          value_type: FLOAT
          description: 'Number of rows inserted by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_inserted
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: queries
        - uuid: fc8f68f5068240f3acd2d18443efc624
          name: 'Dbstat: Rows returned per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_returned.rate
          value_type: FLOAT
          description: 'Number of rows returned by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_returned
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 802d541dd0314f8fba827e6d28013b5c
          name: 'Dbstat: Rows updated per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_updated.rate
          value_type: FLOAT
          description: 'Number of rows updated by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_updated
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: queries
        - uuid: c00a09d04d4443d885006b29c5c14546
          name: 'Dbstat: Committed transactions per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.xact_commit.rate
          value_type: FLOAT
          description: 'Number of transactions that have been committed per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.xact_commit
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: 8f2259521add4cc0bd5e274604172d04
          name: 'Dbstat: Roll backed transactions per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.xact_rollback.rate
          value_type: FLOAT
          description: 'Number of transactions that have been rolled back per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.xact_rollback
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.dbstat.sum,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: 59722a42ba084a4f9a65f6b11f1180f4
          name: 'WAL: Segments count'
          type: DEPENDENT
          key: pgsql.wal.count
          description: 'Number of WAL segments.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.count
          master_item:
            key: 'db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: wal
        - uuid: 5ffd0e54dd464b5c941ba40b696beda9
          name: 'WAL: Bytes received'
          type: DEPENDENT
          key: pgsql.wal.receive
          units: B
          description: 'WAL receive, in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.receive
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: wal
        - uuid: 0dec7fe5cbe24fcf802cb387ca8edf98
          name: 'WAL: Bytes written'
          type: DEPENDENT
          key: pgsql.wal.write
          units: B
          description: 'WAL write, in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.write
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'db.odbc.select[pgsql.wal.stat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          tags:
            - tag: component
              value: wal
      discovery_rules:
        - uuid: 1c51decca55847a8adba4260f53e0acf
          name: 'Database discovery'
          type: ODBC
          key: 'db.odbc.select[pgsql.db.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          delay: 1h
          params: |
            WITH T AS (
              SELECT
                datname AS "{#DBNAME}"
              FROM pg_database
              WHERE
                NOT datistemplate
                AND datallowconn
                AND datname != 'postgres'
            )
            SELECT '{"data":'|| regexp_replace(coalesce(json_agg(T), '[]'::json)::text, E'[\\n\\r\\s]+', '', 'g') || '}'
            FROM T
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DBNAME}'
                value: '{$PG.LLD.FILTER.DBNAME}'
          description: |
            Discovers databases (DB) in the database management system (DBMS), except:
            - templates;
            - default "postgres" DB;
            - DBs that do not allow connections.
          item_prototypes:
            - uuid: 98b74e578a3e48f3990bc16eb0217a17
              name: 'DB [{#DBNAME}]: Database age'
              type: ODBC
              key: 'db.odbc.select[pgsql.db.age,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"]'
              delay: 10m
              params: |
                SELECT age(datfrozenxid)
                  FROM pg_catalog.pg_database
                  WHERE datname = '{#DBNAME}'
              username: '{$PG.USER}'
              password: '{$PG.PASSWORD}'
              description: 'Database age.'
              tags:
                - tag: component
                  value: application
                - tag: database
                  value: '{#DBNAME}'
            - uuid: cb7067b756bc4b3eb5be2ee2361df6f8
              name: 'DB [{#DBNAME}]: Bloating tables'
              type: ODBC
              key: 'db.odbc.select[pgsql.db.bloating_tables,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"]'
              params: |
                SELECT count(*)
                FROM pg_catalog.pg_stat_all_tables
                WHERE (n_dead_tup/(n_live_tup+n_dead_tup)::float8) > 0.2
                  AND (n_live_tup+n_dead_tup) > 50
              username: '{$PG.USER}'
              password: '{$PG.PASSWORD}'
              description: 'Number of bloating tables.'
              tags:
                - tag: component
                  value: tables
                - tag: database
                  value: '{#DBNAME}'
            - uuid: f6bc4dd7f66a4a399a16230b6a7a8f2d
              name: 'DB [{#DBNAME}]: Database size'
              type: ODBC
              key: 'db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"]'
              delay: 5m
              units: B
              params: 'SELECT pg_database_size(current_database())'
              username: '{$PG.USER}'
              password: '{$PG.PASSWORD}'
              description: 'Database size.'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: d6c61f75147e414a99dfba56ea8ba422
              name: 'DB [{#DBNAME}]: Blocks hit per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blks_hit
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: cache
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 086c614609174dabab3b7a231353f4fa
              name: 'DB [{#DBNAME}]: Disk blocks read per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of disk blocks read per second in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blks_read
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 3ce43b1b7b874278abef353c6c791c95
              name: 'DB [{#DBNAME}]: Disk blocks read time per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blk_read_time.rate["{#DBNAME}"]'
              value_type: FLOAT
              units: s
              description: 'Time spent reading data file blocks by backends per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blk_read_time
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 9c443a5bae6b4b4c84e6272cb254a38e
              name: 'DB [{#DBNAME}]: Disk blocks write time per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blk_write_time.rate["{#DBNAME}"]'
              value_type: FLOAT
              units: s
              description: 'Time spent writing data file blocks by backends per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blk_write_time
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 8a772dae1d8f40978bfcceebfabe87de
              name: 'DB [{#DBNAME}]: Detected conflicts per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of queries canceled due to conflicts with recovery in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.conflicts
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 8dc225c8a2824e5cb62b0ce4dd11dc1e
                  expression: 'min(/PostgreSQL by ODBC/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts (over {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: AVERAGE
                  description: |
                    The primary and standby servers are in many ways loosely connected. Actions on the primary will have an effect on the standby. As a result, there is potential for negative interactions or conflicts between them.
                    https://www.postgresql.org/docs/current/hot-standby.html#HOT-STANDBY-CONFLICT
                  tags:
                    - tag: scope
                      value: performance
            - uuid: c4f382ef370640aa93c265dabe0b6dcd
              name: 'DB [{#DBNAME}]: Detected deadlocks per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of detected deadlocks in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.deadlocks
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: deadlocks
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 7e9c3fad615448deafbd21abdac7936d
                  expression: 'min(/PostgreSQL by ODBC/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Deadlock occurred'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Deadlock occurred (over {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: HIGH
                  description: 'Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m.'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 4e977e75b4044928a75dcdd713be1169
              name: 'DB [{#DBNAME}]: Get dbstat'
              type: DEPENDENT
              key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get dbstat metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'db.odbc.select[pgsql.dbstat,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: d65dc8860c6e4e00aca8dfc35c5e3346
              name: 'DB [{#DBNAME}]: Backends connected'
              type: DEPENDENT
              key: 'pgsql.dbstat.numbackends["{#DBNAME}"]'
              description: 'Number of backends currently connected to this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.numbackends
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: backends
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 65ce0c82404340bbb180bdb734573596
              name: 'DB [{#DBNAME}]: Temp_bytes written per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
              units: B
              description: 'Total amount of data written to temporary files by queries in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.temp_bytes
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 9b079ed6377841ee87005af6ebaaa830
              name: 'DB [{#DBNAME}]: Temp_files created per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
              description: 'Total number of temporary files created by queries in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.temp_files
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 207b2e99c61044e091007f45cceb7088
              name: 'DB [{#DBNAME}]: Tuples deleted per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows deleted by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_deleted
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 7e6add2efe2f4cc79982351c448bd921
              name: 'DB [{#DBNAME}]: Tuples fetched per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows fetched by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_fetched
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 43bb96408a9e4832b7e272770c989593
              name: 'DB [{#DBNAME}]: Tuples inserted per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows inserted by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_inserted
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 638cde24706448d09fa06c9571657a9d
              name: 'DB [{#DBNAME}]: Tuples returned per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of rows returned by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_returned
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 73f71c2f1b9043b48152e91a3e3c41a1
              name: 'DB [{#DBNAME}]: Tuples updated per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows updated by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_updated
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 7ff29324ad4c48b7b28faaf3e16efbd6
              name: 'DB [{#DBNAME}]: Commits per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of transactions in this database that have been committed per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.xact_commit
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: a840bb06684140c8b70406a7f8b14873
              name: 'DB [{#DBNAME}]: Rollbacks per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of transactions in this database that have been rolled back.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.xact_rollback
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: e9fa95b198b14da9b416bd1bc7c00911
              name: 'DB [{#DBNAME}]: Num of accessexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.accessexclusive["{#DBNAME}"]'
              description: 'Number of accessexclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.accessexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: fbc1bb60b8214041b64095672995e8ec
              name: 'DB [{#DBNAME}]: Num of accessshare locks'
              type: DEPENDENT
              key: 'pgsql.locks.accessshare["{#DBNAME}"]'
              description: 'Number of accessshare locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.accessshare
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: a98106f8644b4f77b8e2cf1dc7ed9586
              name: 'DB [{#DBNAME}]: Num of exclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.exclusive["{#DBNAME}"]'
              description: 'Number of exclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.exclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 350ebc4e054c4290a92293ba625c40dd
              name: 'DB [{#DBNAME}]: Get locks'
              type: DEPENDENT
              key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get locks metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'db.odbc.select[pgsql.locks,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 0abfbce470824232a7516747f6f2714a
              name: 'DB [{#DBNAME}]: Num of rowexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.rowexclusive["{#DBNAME}"]'
              description: 'Number of rowexclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rowexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 24347f06596f4fc1af2753fbdd0b720c
              name: 'DB [{#DBNAME}]: Num of rowshare locks'
              type: DEPENDENT
              key: 'pgsql.locks.rowshare["{#DBNAME}"]'
              description: 'Number of rowshare locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}''].rowshare'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: dedcbbc9ee234e778b48947561077850
              name: 'DB [{#DBNAME}]: Num of sharerowexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.sharerowexclusive["{#DBNAME}"]'
              description: 'Number of total sharerowexclusive for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.sharerowexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: acaaf4e4ae97426589ea7fe351da0a48
              name: 'DB [{#DBNAME}]: Num of shareupdateexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.shareupdateexclusive["{#DBNAME}"]'
              description: 'Number of shareupdateexclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.shareupdateexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 03df53fbfc2f4ac2a5d0793e0ed14f4c
              name: 'DB [{#DBNAME}]: Num of share locks'
              type: DEPENDENT
              key: 'pgsql.locks.share["{#DBNAME}"]'
              description: 'Number of share locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.share
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 02f319126deb4de19d95443304d97c0d
              name: 'DB [{#DBNAME}]: Num of locks total'
              type: DEPENDENT
              key: 'pgsql.locks.total["{#DBNAME}"]'
              description: 'Total number of locks in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.total
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 16fd0bd835fd4db7b5ebb635780d9fe6
              name: 'DB [{#DBNAME}]: Get queries'
              type: DEPENDENT
              key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get queries metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'db.odbc.select[pgsql.queries,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 100a8f6b18644a308f8117913862dcf4
              name: 'DB [{#DBNAME}]: Queries slow maintenance count'
              type: DEPENDENT
              key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
              description: 'Slow maintenance query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: f430eda6eae54a918a03b27f34709f54
              name: 'DB [{#DBNAME}]: Queries max maintenance time'
              type: DEPENDENT
              key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
              units: s
              description: 'Max maintenance query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 856a7e26192848e1aadb5bdff25cb92a
              name: 'DB [{#DBNAME}]: Queries sum maintenance time'
              type: DEPENDENT
              key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum maintenance query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: b324beea02f742c381d8241ba1e9382b
              name: 'DB [{#DBNAME}]: Queries slow query count'
              type: DEPENDENT
              key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
              description: 'Slow query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: bc790cd8e2c24638ad8a6552af1b9bbe
                  expression: 'min(/PostgreSQL by ODBC/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Too many slow queries'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Too many slow queries (over {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: WARNING
                  description: 'The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}.'
                  tags:
                    - tag: scope
                      value: performance
            - uuid: 0c0717a146344ec4a7abf4e6c35cb7ae
              name: 'DB [{#DBNAME}]: Queries max query time'
              type: DEPENDENT
              key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
              units: s
              description: 'Max query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: e2e686428e2b4f65b7dcbb9a6a3b0f93
              name: 'DB [{#DBNAME}]: Queries sum query time'
              type: DEPENDENT
              key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 06fb68c43e0144e8aa85c0acceeafbfc
              name: 'DB [{#DBNAME}]: Queries slow transaction count'
              type: DEPENDENT
              key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
              description: 'Slow transaction query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 0eced9bbc0d94332a1ec9fb45913b931
              name: 'DB [{#DBNAME}]: Queries max transaction time'
              type: DEPENDENT
              key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
              units: s
              description: 'Max transaction query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: a51a95891cd849de9eeaa6c4dbcbefbe
              name: 'DB [{#DBNAME}]: Queries sum transaction time'
              type: DEPENDENT
              key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum transaction query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
          graph_prototypes:
            - uuid: 7b2e7e0542174a7a996bac8014f9a664
              name: 'DB [{#DBNAME}]: Locks'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.locks.total["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.locks.accessexclusive["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.locks.accessshare["{#DBNAME}"]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.locks.exclusive["{#DBNAME}"]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.locks.rowexclusive["{#DBNAME}"]'
                - sortorder: '5'
                  color: 6C59DC
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.locks.rowshare["{#DBNAME}"]'
                - sortorder: '6'
                  color: C7A72D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.locks.sharerowexclusive["{#DBNAME}"]'
                - sortorder: '7'
                  color: BA2A5D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.locks.shareupdateexclusive["{#DBNAME}"]'
                - sortorder: '8'
                  color: F230E0
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.locks.share["{#DBNAME}"]'
            - uuid: 70065416f33d4a3a9046576a344e965a
              name: 'DB [{#DBNAME}]: Number of bloating tables'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'db.odbc.select[pgsql.db.bloating_tables,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"]'
            - uuid: f9162816d4f740dd8e4863c726b64105
              name: 'DB [{#DBNAME}]: pg_stat_database metrics'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
                - sortorder: '5'
                  color: 6C59DC
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
                - sortorder: '6'
                  color: C7A72D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
                - sortorder: '7'
                  color: BA2A5D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
                - sortorder: '8'
                  color: F230E0
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
                - sortorder: '9'
                  color: 5CCD18
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
                - sortorder: '10'
                  color: BB2A02
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
                - sortorder: '11'
                  color: AC41A5
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
                - sortorder: '12'
                  color: 89ABF8
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
            - uuid: 79b2ba5736054e8a93e70d7af063a0b9
              name: 'DB [{#DBNAME}]: Queries'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
                - sortorder: '3'
                  drawtype: GRADIENT_LINE
                  color: F7941D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
                - sortorder: '4'
                  drawtype: GRADIENT_LINE
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
                - sortorder: '5'
                  drawtype: GRADIENT_LINE
                  color: 6C59DC
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
            - uuid: 7ee8911784824e8380dd07235779a5ea
              name: 'DB [{#DBNAME}]: Size'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'db.odbc.select[pgsql.db.size,,"Database={#DBNAME};{$PG.CONNSTRING.ODBC}"]'
            - uuid: 88a09d63e9214cf1bf8ee82ae485f442
              name: 'DB [{#DBNAME}]: Slow queries'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
        - uuid: 46a6f3cdfff244a28cb712c4186afc7f
          name: 'Replication discovery'
          type: ODBC
          key: 'db.odbc.select[pgsql.replication.process.discovery,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
          delay: 15m
          params: |
            SELECT json_build_object('data',COALESCE(json_agg(json_build_object('{#APPLICATION_NAME}',application_name)), '[]'))		
            FROM pg_stat_replication
          username: '{$PG.USER}'
          password: '{$PG.PASSWORD}'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#APPLICATION_NAME}'
                value: '{$PG.LLD.FILTER.APPLICATION}'
          description: 'Discovers replication lag metrics.'
          item_prototypes:
            - uuid: 9e7797789d2c47efb9af2c86f8c6a93e
              name: 'Application [{#APPLICATION_NAME}]: Get replication'
              type: DEPENDENT
              key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Collect metrics from the "pg_stat_replication" about the application "{#APPLICATION_NAME}" that is connected to this WAL sender, which contains information about the WAL sender process, showing statistics about replication to that sender''s connected standby server.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#APPLICATION_NAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'db.odbc.select[pgsql.replication.process,,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: raw
            - uuid: 86109b6d1b084de186dcda5d455da992
              name: 'Application [{#APPLICATION_NAME}]: Replication flush lag'
              type: DEPENDENT
              key: 'pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"]'
              value_type: FLOAT
              units: s
              description: 'Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written and flushed it (but not yet applied it). This can be used to gauge the delay that synchronous_commit level on incurred while committing if this server was configured as a synchronous standby.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.flush_lag
              master_item:
                key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: replication
            - uuid: 2cad17fa29c24f0da0fffe962c337f13
              name: 'Application [{#APPLICATION_NAME}]: Replication replay lag'
              type: DEPENDENT
              key: 'pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"]'
              value_type: FLOAT
              units: s
              description: 'Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written, flushed and applied it. This can be used to gauge the delay that synchronous_commit level remote_apply incurred while committing if this server was configured as a synchronous standby.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.replay_lag
              master_item:
                key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: replication
            - uuid: f5f62a5cac254d5eb891beadd6ca950d
              name: 'Application [{#APPLICATION_NAME}]: Replication write lag'
              type: DEPENDENT
              key: 'pgsql.replication.process.write_lag["{#APPLICATION_NAME}"]'
              value_type: FLOAT
              units: s
              description: 'Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written it (but not yet flushed it or applied it). This can be used to gauge the delay that synchronous_commit level remote_write incurred while committing if this server was configured as a synchronous standby.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.write_lag
              master_item:
                key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: replication
          graph_prototypes:
            - uuid: 52b70e3a3691467d8ca7a420d2f7f3c5
              name: 'Application [{#APPLICATION_NAME}]: Replication lag'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by ODBC'
                    key: 'pgsql.replication.process.write_lag["{#APPLICATION_NAME}"]'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: fee729c8c626409ba1849e0f6d99392c
          name: 'Bgwriter metrics discovery (versions above 17)'
          type: DEPENDENT
          key: pgsql.bgwriter.above_17.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#BELOW_V17}'
                value: 'false'
          description: 'Discovers "bgwriter" metrics for PostgreSQL version 17 and above.'
          item_prototypes:
            - uuid: 46c4d56f21b24f4face87858445e7b5e
              name: 'Get bgwriter{#SINGLETON}'
              type: ODBC
              key: 'db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              history: '0'
              value_type: TEXT
              params: |
                SELECT row_to_json(T) FROM (
                  SELECT
                    psc.num_timed AS checkpoints_timed,
                    psc.num_requested AS checkpoints_req,
                    psc.write_time AS checkpoint_write_time,
                    psc.sync_time AS checkpoint_sync_time,
                    psc.buffers_written AS buffers_checkpoint,
                    psb.buffers_clean AS buffers_clean,
                    psb.maxwritten_clean AS maxwritten_clean,
                    psb.buffers_alloc AS buffers_alloc
                  FROM
                    pg_stat_checkpointer AS psc,
                    pg_stat_bgwriter AS psb
                ) T
              username: '{$PG.USER}'
              password: '{$PG.PASSWORD}'
              description: |
                Collect all metrics from pg_stat_bgwriter:
                https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW
              tags:
                - tag: component
                  value: raw
            - uuid: 7c2521a1c02240d6846344cc447ffd45
              name: 'Bgwriter: Buffers allocated per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.buffers_alloc.rate.above_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of buffers allocated per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.buffers_alloc
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: 52123eb6463b4d7d990a66398d773e0c
              name: 'Checkpoint: Buffers written during checkpoints per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.buffers_checkpoint.rate.above_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of buffers written during checkpoints per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.buffers_checkpoint
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: e29ed04f09044901a25e3865acf98965
              name: 'Checkpoint: Buffers written by the background writer per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.buffers_clean.rate.above_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of buffers written by the background writer per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.buffers_clean
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: 28219abecf7a44ff948ce97840263b41
              name: 'Checkpoint: Requested per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.checkpoints_req.rate.above_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of requested checkpoints that have been performed per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.checkpoints_req
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: 8065cdd159d84ea69b99983abf0d6beb
              name: 'Checkpoint: Scheduled per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.checkpoints_timed.rate.above_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of scheduled checkpoints that have been performed per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.checkpoints_timed
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: 5a5d84878d22478aa856228b4486b55d
              name: 'Bgwriter: Checkpoint sync time per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.checkpoint_sync_time.rate.above_17[{#SINGLETON}]'
              value_type: FLOAT
              units: s
              description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.checkpoint_sync_time
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: a84ae8aceaf44abaa33d925757b71b8f
              name: 'Checkpoint: Checkpoint write time per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.checkpoint_write_time.rate.above_17[{#SINGLETON}]'
              value_type: FLOAT
              units: s
              description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.checkpoint_write_time
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: 70d6cea0481741d08a572e732b3e237d
              name: 'Bgwriter: Number of bgwriter cleaning scan stopped per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.maxwritten_clean.rate.above_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of times the background writer stopped a cleaning scan because it had written too many buffers per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.maxwritten_clean
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.above_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
          master_item:
            key: pgsql.bgwriter.lld
        - uuid: fcbd89dc14aa4bd99446016d453f850d
          name: 'Bgwriter metrics discovery (versions below 17)'
          type: DEPENDENT
          key: pgsql.bgwriter.below_17.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#BELOW_V17}'
                value: 'true'
          description: 'Discovers "bgwriter" metrics for PostgreSQL below version 17.'
          item_prototypes:
            - uuid: 777e615655634c8bae2e13cef153314b
              name: 'Get bgwriter{#SINGLETON}'
              type: ODBC
              key: 'db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              history: '0'
              value_type: TEXT
              params: |
                SELECT row_to_json(T) FROM (
                  SELECT checkpoints_timed,
                    checkpoints_req,
                    checkpoint_write_time,
                    checkpoint_sync_time,
                    buffers_checkpoint AS buffers_checkpoint,
                    buffers_clean AS buffers_clean,
                    maxwritten_clean,
                    buffers_backend AS buffers_backend,
                    buffers_backend_fsync,
                    buffers_alloc AS buffers_alloc
                  FROM pg_stat_bgwriter) T
              username: '{$PG.USER}'
              password: '{$PG.PASSWORD}'
              description: |
                Collect all metrics from pg_stat_bgwriter:
                https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW
              tags:
                - tag: component
                  value: raw
            - uuid: cc397d603cec450593a9871dd39e6db6
              name: 'Bgwriter: Buffers allocated per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.buffers_alloc.rate.below_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of buffers allocated per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.buffers_alloc
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: 09f43b8bf08c41839ef48f8aefc5dd39
              name: 'Bgwriter: Buffers written directly by a backend per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.buffers_backend.rate.below_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of buffers written directly by a backend per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.buffers_backend
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: b734c475147040bfa431390e6b524f4c
              name: 'Bgwriter: Times a backend executed its own fsync per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.buffers_backend_fsync.rate.below_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of times a backend had to execute its own fsync call per second (normally the background writer handles those even when the backend does its own write).'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.buffers_backend_fsync
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: 38ea04f3a47f4dcda9b61c6866c0efe3
              name: 'Checkpoint: Buffers written during checkpoints per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.buffers_checkpoint.rate.below_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of buffers written during checkpoints per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.buffers_checkpoint
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: 9cf1b0c328d34490a66f79b32be20efd
              name: 'Checkpoint: Buffers written by the background writer per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.buffers_clean.rate.below_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of buffers written by the background writer per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.buffers_clean
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: 05340503596c48b7b3e7ce763e1b22ef
              name: 'Checkpoint: Requested per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.checkpoints_req.rate.below_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of requested checkpoints that have been performed per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.checkpoints_req
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: 18f66c4149444c7b8b0190ac74488859
              name: 'Checkpoint: Scheduled per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.checkpoints_timed.rate.below_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of scheduled checkpoints that have been performed per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.checkpoints_timed
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: e7d10f58ada9468abc4ad7b4a9900c1c
              name: 'Bgwriter: Checkpoint sync time per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.checkpoint_sync_time.rate.below_17[{#SINGLETON}]'
              value_type: FLOAT
              units: s
              description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.checkpoint_sync_time
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: c7810e79f2d94f0e9a4f462d76b10a24
              name: 'Checkpoint: Checkpoint write time per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.checkpoint_write_time.rate.below_17[{#SINGLETON}]'
              value_type: FLOAT
              units: s
              description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.checkpoint_write_time
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
            - uuid: 987ad2df6df14f1eabe2b1c6eb6713fc
              name: 'Bgwriter: Number of bgwriter cleaning scan stopped per second{#SINGLETON}'
              type: DEPENDENT
              key: 'pgsql.bgwriter.maxwritten_clean.rate.below_17[{#SINGLETON}]'
              value_type: FLOAT
              description: 'Number of times the background writer stopped a cleaning scan because it had written too many buffers per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.maxwritten_clean
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'db.odbc.select[pgsql.bgwriter.below_17{#SINGLETON},,"Database={$PG.DATABASE};{$PG.CONNSTRING.ODBC}"]'
              tags:
                - tag: component
                  value: bgwriter
          master_item:
            key: pgsql.bgwriter.lld
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: postgresql
      macros:
        - macro: '{$PG.CONFLICTS.MAX.WARN}'
          value: '0'
          description: 'Maximum number of recovery conflicts for trigger expression.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Maximum number of recovery conflicts'
            description: 'Maximum number of recovery conflicts for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.CONNSTRING.ODBC}'
          value: Servername=localhost;Port=5432;Driver=/usr/lib64/psqlodbcw.so
          description: 'Connection string for the PostgreSQL instance.'
          config:
            type: TEXT
            priority: '1'
            label: 'PostgreSQL connection string'
            description: 'Connection string for the PostgreSQL instance.'
            required: 'YES'
        - macro: '{$PG.CONN_TOTAL_PCT.MAX.WARN}'
          value: '90'
          description: 'Maximum percentage of current connections for trigger expression.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Maximum percentage of current connections'
            description: 'Maximum percentage of current connections for trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.DATABASE}'
          value: postgres
          description: 'Default PostgreSQL database for the connection.'
          config:
            type: TEXT
            priority: '4'
            label: 'Default PostgreSQL database for the connection'
            required: 'YES'
        - macro: '{$PG.DEADLOCKS.MAX.WARN}'
          value: '0'
          description: 'Maximum number of detected deadlocks for trigger expression.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Maximum number of detected deadlocks'
            description: 'Maximum number of detected deadlocks for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.LLD.FILTER.APPLICATION}'
          value: .+
          description: 'Filter of discoverable applications.'
          config:
            type: TEXT
            priority: '6'
            section_name: Filters
            label: 'Applications LLD filter'
            description: 'Filter of discoverable applications.'
        - macro: '{$PG.LLD.FILTER.DBNAME}'
          value: .+
          description: 'Filter of discoverable databases.'
          config:
            type: TEXT
            priority: '5'
            section_name: Filters
            label: 'Database name LLD filter'
            description: 'Filter of discoverable databases.'
        - macro: '{$PG.PASSWORD}'
          type: SECRET_TEXT
          description: 'PostgreSQL user password.'
          config:
            type: TEXT
            priority: '3'
            label: 'PostgreSQL user password'
            required: 'YES'
        - macro: '{$PG.QUERY_ETIME.MAX.WARN}'
          value: '30'
          description: 'Execution time limit for count of slow queries.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'Slow queries execution time threshold'
            description: 'Execution time threshold for queries to be considered slow. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.SLOW_QUERIES.MAX.WARN}'
          value: '5'
          description: 'Slow queries count threshold for a trigger.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'Slow queries count threshold'
            description: 'Slow queries count threshold for a trigger. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.USER}'
          value: zbx_monitor
          description: 'PostgreSQL username.'
          config:
            type: TEXT
            priority: '2'
            label: 'PostgreSQL username'
            required: 'YES'
      dashboards:
        - uuid: 6f15f8b6e90b4d09b9e1d4fb323ac438
          name: 'PostgreSQL databases'
          pages:
            - widgets:
                - type: graphprototype
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by ODBC'
                        name: 'DB [{#DBNAME}]: pg_stat_database metrics'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graphprototype
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by ODBC'
                        name: 'DB [{#DBNAME}]: Size'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graphprototype
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by ODBC'
                        name: 'DB [{#DBNAME}]: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graphprototype
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by ODBC'
                        name: 'DB [{#DBNAME}]: Locks'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graphprototype
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by ODBC'
                        name: 'DB [{#DBNAME}]: Number of bloating tables'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graphprototype
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by ODBC'
                        name: 'DB [{#DBNAME}]: Slow queries'
                    - type: STRING
                      name: reference
                      value: AAAAF
      valuemaps:
        - uuid: 6e5062ae5345454f95cb8608b35eddf4
          name: 'PostgreSQL recovery role'
          mappings:
            - value: '0'
              newvalue: Master
            - value: '1'
              newvalue: Standby
        - uuid: 75393338fb514612a5f0ba57cec318b3
          name: 'PostgreSQL replication status'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
            - value: '2'
              newvalue: Master
        - uuid: f2af00a32d1e471a98b9e4e6148f68f3
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: 399bd1ee587245ecac6f39beaa99886f
      template: 'PostgreSQL by Zabbix agent'
      name: 'PostgreSQL by Zabbix agent'
      description: |
        This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent and uses user parameters to run SQL queries with the `psql` command-line tool.
        
        Note:
        - The template requires `pg_isready` and `psql` utilities to be installed on the same host with Zabbix agent.
        - The template requires files with SQL queries and user parameters that can be found in the Zabbix official repository:
        https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql?at=refs%2Fheads%2Frelease%2F6.0
        
        Setup:
        
        1. Deploy Zabbix agent and create the PostgreSQL user for monitoring (`<password>` at your discretion) with proper access rights to your PostgreSQL instance.
        
        For PostgreSQL version 10 and above:
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
        GRANT pg_monitor TO zbx_monitor;
        
        For PostgreSQL version 9.6 and below:
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>';
        GRANT SELECT ON pg_stat_database TO zbx_monitor;
        ALTER USER zbx_monitor WITH SUPERUSER;
        
        2. Copy the `postgresql/` directory to the `zabbix` user home directory - `/var/lib/zabbix/`. The `postgresql/` directory contains the files with SQL queries needed to obtain metrics from PostgreSQL instance.
        
        If the home directory of the `zabbix` user doesn't exist, create it first:
        mkdir -m u=rwx,g=rwx,o= -p /var/lib/zabbix
        chown zabbix:zabbix /var/lib/zabbix
        
        3. Copy the `template_db_postgresql.conf` file, containing user parameters, to the Zabbix agent configuration directory `/etc/zabbix/zabbix_agentd.d/` and restart Zabbix agent service.
        
        If you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, you can modify the connection string in user parameters. For example, to enable required encryption in transport mode without identity checks you could append `?sslmode=required` to the end of the connection string for all keys that use `psql`:
        UserParameter=pgsql.bgwriter[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5"?sslmode=required -f "/var/lib/zabbix/postgresql/pgsql.bgwriter.sql"
        
        Consult the PostgreSQL documentation about protection modes (https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-PROTECTION) and client connection parameters (https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLMODE).
        
        Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation (https://www.postgresql.org/docs/current/ssl-tcp.html) for details.
        
        4. Edit the `pg_hba.conf` configuration file to allow connections for the user `zbx_monitor`. You can check the PostgreSQL documentation for examples (https://www.postgresql.org/docs/current/auth-pg-hba-conf.html).
        
        5. Specify the host name or IP address in the `{$PG.HOST}` macro. Adjust the port number with `{$PG.PORT}` macro if needed.
        
        6. Set the password that you specified in step 1 in the macro `{$PG.PASSWORD}`.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384190-%C2%A0discussion-thread-for-official-zabbix-template-db-postgresql
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Overview
        
        This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent and uses user parameters to run SQL queries with the `psql` command-line tool.
        
        ## Setup
        
        **Note:**
        - The template requires `pg_isready` and `psql` utilities to be installed on the same host with Zabbix agent.
        
        1. Create the PostgreSQL user for monitoring (`<password>` at your discretion) with proper access rights to your PostgreSQL instance.
        
        For PostgreSQL version 10 and above:
        
        ```sql
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
        GRANT pg_monitor TO zbx_monitor;
        ```
        
        For PostgreSQL version 9.6 and below:
        
        ```sql
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>';
        GRANT SELECT ON pg_stat_database TO zbx_monitor;
        
        -- To collect WAL metrics, the user must have a `superuser` role.
        ALTER USER zbx_monitor WITH SUPERUSER;
        ```
        
        2. Copy the `postgresql/` directory to the `zabbix` user home directory - `/var/lib/zabbix/`. The `postgresql/` directory contains the files with SQL queries needed to obtain metrics from PostgreSQL instance.
        
        If the home directory of the `zabbix` user doesn't exist, create it first:
        
        ```bash
        mkdir -m u=rwx,g=rwx,o= -p /var/lib/zabbix
        chown zabbix:zabbix /var/lib/zabbix
        ```
        
        3. Copy the `template_db_postgresql.conf` file, containing user parameters, to the Zabbix agent configuration directory `/etc/zabbix/zabbix_agentd.d/` and restart Zabbix agent service.
        
        **Note:** if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, you can modify the connection string in user parameters. For example, to enable required encryption in transport mode without identity checks you could append `?sslmode=required` to the end of the connection string for all keys that use `psql`:
        
        ```bash
        UserParameter=pgsql.bgwriter[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5"?sslmode=required -f "/var/lib/zabbix/postgresql/pgsql.bgwriter.sql"
        ```
        
        Consult the PostgreSQL documentation about [`protection modes`](https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-PROTECTION) and [`client connection parameters`](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLMODE).
        
        Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the [`PostgreSQL documentation`](https://www.postgresql.org/docs/current/ssl-tcp.html) for details.
        
        4. Edit the `pg_hba.conf` configuration file to allow connections for the user `zbx_monitor`. For example, you could add one of the following rows to allow local TCP connections from the same host:
        
        ```bash
        # TYPE  DATABASE        USER            ADDRESS                 METHOD
          host       all        zbx_monitor     localhost               trust
          host       all        zbx_monitor     127.0.0.1/32            md5
          host       all        zbx_monitor     ::1/128                 scram-sha-256
        ```
        
        For more information please read the PostgreSQL documentation `https://www.postgresql.org/docs/current/auth-pg-hba-conf.html`.
        
        5. Specify the host name or IP address in the `PostgreSQL host` host wizard configuration field. Adjust the port number in the `PostgreSQL port` field if needed.
        
        6. Set the password that you specified in step 1 in the `PostgreSQL user password` field.
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Databases
      items:
        - uuid: d17c6c15154d40d1afa5b1eafb2ed93e
          name: 'Bgwriter: Buffers allocated per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_alloc.rate
          value_type: FLOAT
          description: 'Number of buffers allocated per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_alloc
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 2c3ee691d4a54fb6b566739a3a648df4
          name: 'Bgwriter: Buffers written directly by a backend per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_backend.rate
          value_type: FLOAT
          description: 'Number of buffers written directly by a backend per second. Available in PostgreSQL versions prior to 17.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_backend
              error_handler: DISCARD_VALUE
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 77e1eb202a6346ce9df0f1bb2c078688
          name: 'Bgwriter: Times a backend executed its own fsync per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_backend_fsync.rate
          value_type: FLOAT
          description: 'Number of times a backend had to execute its own fsync call per second (normally the background writer handles those even when the backend does its own write). Available in PostgreSQL versions prior to 17.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_backend_fsync
              error_handler: DISCARD_VALUE
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: e29d26a48d0143579bf3acc6655cd659
          name: 'Checkpoint: Buffers written during checkpoints per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_checkpoint.rate
          value_type: FLOAT
          description: 'Number of buffers written during checkpoints per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_checkpoint
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 5151183461a54d2bbfaad04b8cab3798
          name: 'Checkpoint: Buffers written by the background writer per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_clean.rate
          value_type: FLOAT
          description: 'Number of buffers written by the background writer per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_clean
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: ff290c0602b9447e87240c1ecf467050
          name: 'Checkpoint: Requested per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoints_req.rate
          value_type: FLOAT
          description: 'Number of requested checkpoints that have been performed per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoints_req
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
          triggers:
            - uuid: 65e7954489854ad3ad1698dead7c4c02
              expression: 'last(/PostgreSQL by Zabbix agent/pgsql.bgwriter.checkpoints_req.rate) > {$PG.CHECKPOINTS_REQ.MAX.WARN}'
              name: 'PostgreSQL: Required checkpoints occur too frequently'
              event_name: 'PostgreSQL: Required checkpoints occur too frequently (over {$PG.CHECKPOINTS_REQ.MAX.WARN})'
              priority: AVERAGE
              description: |
                Checkpoints are points in the sequence of transactions at which it is guaranteed that the heap and index data files have been updated with all information written before that checkpoint. At checkpoint time, all dirty data pages are flushed to disk and a special checkpoint record is written to the log file.
                https://www.postgresql.org/docs/current/wal-configuration.html
              tags:
                - tag: scope
                  value: performance
        - uuid: a5271230be8b431cb96580180e099b98
          name: 'Checkpoint: Scheduled per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoints_timed.rate
          value_type: FLOAT
          description: 'Number of scheduled checkpoints that have been performed per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoints_timed
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 782d2368763b48ad8663aa9fb75c3326
          name: 'Checkpoint: Checkpoint sync time per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoint_sync_time.rate
          value_type: FLOAT
          units: s
          description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoint_sync_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: b5e5f463978c46dd9401963f48ea72eb
          name: 'Checkpoint: Checkpoint write time per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoint_write_time.rate
          value_type: FLOAT
          units: s
          description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoint_write_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: f273c71f92bf4ac0b6ec5a0a88d1239c
          name: 'Bgwriter: Number of bgwriter cleaning scan stopped per second'
          type: DEPENDENT
          key: pgsql.bgwriter.maxwritten_clean.rate
          value_type: FLOAT
          description: 'Number of times the background writer stopped a cleaning scan because it had written too many buffers per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.maxwritten_clean
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 1fc5ba48a0974bd7bf965b5f130deded
          name: 'Get bgwriter'
          key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: 1h
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_bgwriter:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: 768d28b9360b46cda3065f5082ba97ac
              expression: 'nodata(/PostgreSQL by Zabbix agent/pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],30m) = 1'
              name: 'PostgreSQL: Failed to get items'
              event_name: 'PostgreSQL: Failed to get items (no data for 30m)'
              priority: WARNING
              description: 'Zabbix has not received any data for items for the last 30 minutes.'
              dependencies:
                - name: 'PostgreSQL: Service is down'
                  expression: 'last(/PostgreSQL by Zabbix agent/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 70a7581fabd14e05bda762b79811187c
          name: 'Cache hit ratio, %'
          key: 'pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          value_type: FLOAT
          units: '%'
          description: 'Cache hit ratio.'
          tags:
            - tag: component
              value: cache
          triggers:
            - uuid: 4d87cc71b40f4b59ad27f30f33b15a69
              expression: 'max(/PostgreSQL by Zabbix agent/pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) < {$PG.CACHE_HITRATIO.MIN.WARN}'
              name: 'PostgreSQL: Cache hit ratio too low'
              event_name: 'PostgreSQL: Cache hit ratio too low (under {$PG.CACHE_HITRATIO.MIN.WARN} in 5m)'
              priority: WARNING
              description: 'Cache hit ratio is lower than {$PG.CACHE_HITRATIO.MIN.WARN} for 5m.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 248cbe5067324b9ca435f2aced5e2a5f
          name: 'Config hash'
          key: 'pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 15m
          value_type: TEXT
          description: 'PostgreSQL configuration hash.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: b727cfa6d3de4063b6a2dcb6cc84e27b
              expression: 'last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0'
              name: 'PostgreSQL: Configuration has changed'
              priority: INFO
              description: 'PostgreSQL configuration has changed.'
              tags:
                - tag: scope
                  value: notice
        - uuid: c78116d3acf24e6990ed27ba8008728c
          name: 'Connections sum: Active'
          type: DEPENDENT
          key: pgsql.connections.sum.active
          description: 'Total number of connections executing a query.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.active
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: be6eb6ecbfad420b889c58d1f1550b23
          name: 'Connections sum: Idle'
          type: DEPENDENT
          key: pgsql.connections.sum.idle
          description: 'Total number of connections waiting for a new client command.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 6471d014722c4072ae045df4c69578e3
          name: 'Connections sum: Idle in transaction'
          type: DEPENDENT
          key: pgsql.connections.sum.idle_in_transaction
          description: 'Total number of connections in a transaction state but not executing a query.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle_in_transaction
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 197cc14f55db485b891614c7b7ee2a51
          name: 'Connections sum: Prepared'
          type: DEPENDENT
          key: pgsql.connections.sum.prepared
          description: |
            Total number of prepared transactions:
            https://www.postgresql.org/docs/current/sql-prepare-transaction.html
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.prepared
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 24d23377c7cd4cc5b63f98a261c2501c
          name: 'Connections sum: Total'
          type: DEPENDENT
          key: pgsql.connections.sum.total
          description: 'Total number of connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 488050d9aa8e4c2ea5b3e991ec5ddacc
          name: 'Connections sum: Total, %'
          type: DEPENDENT
          key: pgsql.connections.sum.total_pct
          units: '%'
          description: 'Total number of connections, in percentage.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total_pct
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: 54ef12b8ff1e4383a3097c71478ceefa
              expression: 'min(/PostgreSQL by Zabbix agent/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN}'
              name: 'PostgreSQL: Total number of connections is too high'
              event_name: 'PostgreSQL: Total number of connections is too high (over {$PG.CONN_TOTAL_PCT.MAX.WARN} in 5m)'
              priority: AVERAGE
              description: 'Total number of current connections exceeds the limit of {$PG.CONN_TOTAL_PCT.MAX.WARN}% out of the maximum number of concurrent connections to the database server (the "max_connections" setting).'
              tags:
                - tag: scope
                  value: performance
        - uuid: fadd1333189c4ed29db57cf2acd158d0
          name: 'Connections sum: Waiting'
          type: DEPENDENT
          key: pgsql.connections.sum.waiting
          description: |
            Total number of waiting connections:
            https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.waiting
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: b0da0c4856a645ca8ef03405d2d8d4a5
          name: 'Get connections sum'
          key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_activity:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: b44f263fb33e461e8c3d700fb7688c7b
          name: 'Get dbstat'
          key: 'pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_database per database:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: 7cee21f6225340ef80e9cdef7ce20b10
          name: 'Get locks'
          key: 'pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_locks per database:
            https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES
          tags:
            - tag: component
              value: raw
        - uuid: f42bd73b3af6451b8a3a6113dcc1b675
          name: 'Ping time'
          key: 'pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          value_type: FLOAT
          units: s
          description: 'Used to get the `SELECT 1` query execution time.'
          preprocessing:
            - type: REGEX
              parameters:
                - 'Time:\s+(\d+\.\d+)\s+ms'
                - \1
            - type: MULTIPLIER
              parameters:
                - '0.001'
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: e19b5630737b4c63886b5df77a3c748c
              expression: 'min(/PostgreSQL by Zabbix agent/pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) > {$PG.PING_TIME.MAX.WARN}'
              name: 'PostgreSQL: Response too long'
              event_name: 'PostgreSQL: Response too long (over {$PG.PING_TIME.MAX.WARN})'
              priority: AVERAGE
              description: 'Response is taking too long (over {$PG.PING_TIME.MAX.WARN} for 5m).'
              dependencies:
                - name: 'PostgreSQL: Service is down'
                  expression: 'last(/PostgreSQL by Zabbix agent/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0'
              tags:
                - tag: scope
                  value: availability
                - tag: scope
                  value: performance
        - uuid: f5bd615243b344cb88dac1e83436cc85
          name: Ping
          key: 'pgsql.ping["{$PG.HOST}","{$PG.PORT}"]'
          description: 'Used to test a connection to see if it is alive. It is set to 0 if the instance doesn''t accept the connections.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return value.search(/accepting connections/)>0 ? 1 : 0'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: 6d9c2b5353ce4f6baeeb0f254fb7d1e2
              expression: 'last(/PostgreSQL by Zabbix agent/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0'
              name: 'PostgreSQL: Service is down'
              priority: HIGH
              description: 'Last test of a connection was unsuccessful.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 47bf580e1e4e48cf9c0e94fcf90288ac
          name: 'Get queries'
          key: 'pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"]'
          history: '0'
          value_type: TEXT
          description: 'Collect all metrics by query execution time.'
          tags:
            - tag: component
              value: raw
        - uuid: d8a509bd011a4ecda5d439295e257e9d
          name: 'Replication: Standby count'
          key: 'pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Number of standby servers.'
          tags:
            - tag: component
              value: replication
        - uuid: 21f8bea1141249c7a4dfafad5bc3ef41
          name: 'Replication: Lag in seconds'
          key: 'pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          units: s
          description: 'Replication lag with master, in seconds.'
          tags:
            - tag: component
              value: replication
          triggers:
            - uuid: 11831c52e86445498eed42de6a629b65
              expression: 'min(/PostgreSQL by Zabbix agent/pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) > {$PG.REPL_LAG.MAX.WARN}'
              name: 'PostgreSQL: Streaming lag with master is too high'
              event_name: 'PostgreSQL: Streaming lag with master is too high (over {$PG.REPL_LAG.MAX.WARN} in 5m)'
              priority: AVERAGE
              description: 'Replication lag with master is higher than {$PG.REPL_LAG.MAX.WARN} for 5m.'
              tags:
                - tag: scope
                  value: availability
                - tag: scope
                  value: performance
        - uuid: 09f696124fca4c5b844bf66c9c912b87
          name: 'Replication: Recovery role'
          key: 'pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode.'
          valuemap:
            name: 'PostgreSQL recovery role'
          tags:
            - tag: component
              value: replication
        - uuid: d449017462704508a4aad51a6b45fb30
          name: 'Replication: Status'
          key: 'pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode.'
          valuemap:
            name: 'PostgreSQL replication status'
          tags:
            - tag: component
              value: replication
          triggers:
            - uuid: aef1e1d2bab540f8ab738b4a3fad863c
              expression: 'max(/PostgreSQL by Zabbix agent/pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m)=0'
              name: 'PostgreSQL: Replication is down'
              priority: AVERAGE
              description: 'Replication is enabled and data streaming was down for 5m.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 4883717865c84c19b48d46f009317de2
          name: 'Transactions: Max active transaction time'
          type: DEPENDENT
          key: pgsql.transactions.active
          value_type: FLOAT
          units: s
          description: 'Current max active transaction time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.active
          master_item:
            key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: 4c89121d71a14c15b6169417ea69d0a3
          name: 'Transactions: Max idle transaction time'
          type: DEPENDENT
          key: pgsql.transactions.idle
          value_type: FLOAT
          units: s
          description: 'Current max idle transaction time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle
          master_item:
            key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: 0ee43ddd9da246d19097107b45e4c8e8
          name: 'Transactions: Max prepared transaction time'
          type: DEPENDENT
          key: pgsql.transactions.prepared
          value_type: FLOAT
          units: s
          description: 'Current max prepared transaction time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.prepared
          master_item:
            key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: da341b2011714a1f994ecbe96bd52155
          name: 'Transactions: Max waiting transaction time'
          type: DEPENDENT
          key: pgsql.transactions.waiting
          value_type: FLOAT
          units: s
          description: 'Current max waiting transaction time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.waiting
          master_item:
            key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: ff26a1c256bd40978f49a7a025538aa1
          name: 'Get transactions'
          key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: 'Collect metrics by transaction execution time.'
          tags:
            - tag: component
              value: raw
        - uuid: 6418a2f286e64ecabf2295fca063f8af
          name: Uptime
          key: 'pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          units: uptime
          description: 'Time since the server started.'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 85565aba402740868a16c0e4639a98fc
              expression: 'last(/PostgreSQL by Zabbix agent/pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m'
              name: 'PostgreSQL: Service has been restarted'
              event_name: 'PostgreSQL: Service has been restarted (uptime < 10m)'
              priority: AVERAGE
              description: 'PostgreSQL uptime is less than 10 minutes.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 321525ebcea44396922e96deec2e8ad1
          name: Version
          key: 'pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 15m
          value_type: CHAR
          description: 'PostgreSQL version.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 8111eb42b0e74fffb43da474677ebc2f
              expression: 'last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0'
              name: 'PostgreSQL: Version has changed'
              event_name: 'PostgreSQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              tags:
                - tag: scope
                  value: notice
        - uuid: 5385ec7d39514039a641d18cba335ddc
          name: 'WAL: Segments count'
          type: DEPENDENT
          key: pgsql.wal.count
          description: 'Number of WAL segments.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.count
          master_item:
            key: 'pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: wal
        - uuid: 7cd6c524ecab41f9a22489866d503361
          name: 'Get WAL'
          key: 'pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 5m
          history: '0'
          value_type: TEXT
          description: 'Collect write-ahead log (WAL) metrics.'
          tags:
            - tag: component
              value: raw
        - uuid: 5cc9c67621cc46e0a42b1eb79bda83b3
          name: 'WAL: Bytes written'
          type: DEPENDENT
          key: pgsql.wal.write
          units: B
          description: 'WAL write, in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.write
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: wal
      discovery_rules:
        - uuid: 5c4c658507394f5bb362e601f7c59d63
          name: 'Database discovery'
          key: 'pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 1h
          filter:
            conditions:
              - macro: '{#DBNAME}'
                value: '{$PG.LLD.FILTER.DBNAME}'
          description: |
            Discovers databases (DB) in the database management system (DBMS), except:
            - templates;
            - default "postgres" DB;
            - DBs that do not allow connections.
          item_prototypes:
            - uuid: 69575e9785184ef5be2502e3cc282220
              name: 'DB [{#DBNAME}]: Database size'
              key: 'pgsql.db.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#DBNAME}"]'
              delay: 15m
              units: B
              description: 'Database size.'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 615e6567a85e421bb06ab8cac0eaba69
              name: 'DB [{#DBNAME}]: Blocks hit per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blks_hit
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: cache
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 9136517d08b447869e5b8f5fd684c3b9
              name: 'DB [{#DBNAME}]: Disk blocks read per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of disk blocks read per second in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blks_read
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: a76f6d28995441ff9fe28bbc09445e64
              name: 'DB [{#DBNAME}]: Detected conflicts per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of queries canceled due to conflicts with recovery in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.conflicts
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 3b51f02258bd4e02829f04ca016dd01d
                  expression: 'min(/PostgreSQL by Zabbix agent/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts (over {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: AVERAGE
                  description: |
                    The primary and standby servers are in many ways loosely connected. Actions on the primary will have an effect on the standby. As a result, there is potential for negative interactions or conflicts between them.
                    https://www.postgresql.org/docs/current/hot-standby.html#HOT-STANDBY-CONFLICT
                  tags:
                    - tag: scope
                      value: performance
            - uuid: b874cc2dd80643208c2479ad25fae0ac
              name: 'DB [{#DBNAME}]: Detected deadlocks per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of detected deadlocks in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.deadlocks
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: deadlocks
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 3bee63fa04d94586937e22aafab9bdd8
                  expression: 'min(/PostgreSQL by Zabbix agent/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Deadlock occurred'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Deadlock occurred (over {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: HIGH
                  description: 'Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m.'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 52c20fc8faad42ae8d255990ce14d3cd
              name: 'DB [{#DBNAME}]: Get dbstat'
              type: DEPENDENT
              key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get dbstat metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: d235ead54c8b41f9a91398c75383e5d7
              name: 'DB [{#DBNAME}]: Temp_bytes written per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
              units: B
              description: 'Total amount of data written to temporary files by queries in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.temp_bytes
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: af4e35eee1764d3f97d9c1218867f885
              name: 'DB [{#DBNAME}]: Temp_files created per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
              description: 'Total number of temporary files created by queries in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.temp_files
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 35c6f93aefe4439bbc36f2f358440b16
              name: 'DB [{#DBNAME}]: Tuples deleted per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows deleted by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_deleted
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 92f33d96f8a348088cdba593c0e66929
              name: 'DB [{#DBNAME}]: Tuples fetched per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows fetched by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_fetched
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 8c03c87a44fe43928c32087ca7561e88
              name: 'DB [{#DBNAME}]: Tuples inserted per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows inserted by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_inserted
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: f6d378f4e38e455fa5a12467fe977657
              name: 'DB [{#DBNAME}]: Tuples returned per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of rows returned by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_returned
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 4c8de8c1064d43ffa18c4f37fead37f7
              name: 'DB [{#DBNAME}]: Tuples updated per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows updated by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_updated
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 81c33f5b3c31475fa5f28f4ad149a328
              name: 'DB [{#DBNAME}]: Commits per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of transactions in this database that have been committed per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.xact_commit
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 8e5080186d034323be21473099b0b0ce
              name: 'DB [{#DBNAME}]: Rollbacks per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of transactions in this database that have been rolled back.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.xact_rollback
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: df9dd9bac2a54f1085b29fb22b394a1f
              name: 'DB [{#DBNAME}]: Frozen XID before autovacuum, %'
              type: DEPENDENT
              key: 'pgsql.frozenxid.prc_before_av["{#DBNAME}"]'
              value_type: FLOAT
              units: '%'
              description: |
                Preventing Transaction ID Wraparound Failures:
                https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.prc_before_av
              master_item:
                key: 'pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 44ddd66ea37449cb8fab6979b98dfd3c
              name: 'DB [{#DBNAME}]: Frozen XID before stop, %'
              type: DEPENDENT
              key: 'pgsql.frozenxid.prc_before_stop["{#DBNAME}"]'
              value_type: FLOAT
              units: '%'
              description: |
                Preventing Transaction ID Wraparound Failures:
                https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.prc_before_stop
              master_item:
                key: 'pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 709df9c1e29a4ff68a3de9423ff7ae58
                  expression: 'last(/PostgreSQL by Zabbix agent/pgsql.frozenxid.prc_before_stop["{#DBNAME}"])<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound (frozen XID less than {$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} %)'
                  priority: AVERAGE
                  description: |
                    Preventing Transaction ID Wraparound Failures:
                    https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND
                  tags:
                    - tag: scope
                      value: availability
            - uuid: ddf6d0b7b5fe4cbbb540687051b8e5f5
              name: 'DB [{#DBNAME}]: Get frozen XID'
              key: 'pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 3d0acf4b45fc4a72bb2a214222f93f2a
              name: 'DB [{#DBNAME}]: Num of locks total'
              type: DEPENDENT
              key: 'pgsql.locks.total["{#DBNAME}"]'
              description: 'Total number of locks in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}''].total'
              master_item:
                key: 'pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: ef7d3c9866df44aa9b378e7f125a34de
                  expression: 'min(/PostgreSQL by Zabbix agent/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Number of locks is too high'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Number of locks is too high (over {$PG.LOCKS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: WARNING
                  tags:
                    - tag: scope
                      value: availability
            - uuid: ac226e85268c463786e297944339ccf5
              name: 'DB [{#DBNAME}]: Get queries'
              type: DEPENDENT
              key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get queries metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 939ab05c71ed4be9979662203ebba980
              name: 'DB [{#DBNAME}]: Queries slow maintenance count'
              type: DEPENDENT
              key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
              description: 'Slow maintenance query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: bbc8f9bf86394cf28e0c2db44ee4711d
              name: 'DB [{#DBNAME}]: Queries max maintenance time'
              type: DEPENDENT
              key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
              units: s
              description: 'Max maintenance query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: f1427228bfa14ad3b7bb9d63bcfaec59
              name: 'DB [{#DBNAME}]: Queries sum maintenance time'
              type: DEPENDENT
              key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum maintenance query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 5d937f46f4684f1e8253ec62e0f75379
              name: 'DB [{#DBNAME}]: Queries slow query count'
              type: DEPENDENT
              key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
              description: 'Slow query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: facc8f6976664da4ad5567d270f0f311
                  expression: 'min(/PostgreSQL by Zabbix agent/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Too many slow queries'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Too many slow queries (over {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: WARNING
                  description: 'The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}.'
                  tags:
                    - tag: scope
                      value: performance
            - uuid: 044cc16d0a2f46b28d88eff86c33b30b
              name: 'DB [{#DBNAME}]: Queries max query time'
              type: DEPENDENT
              key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
              units: s
              description: 'Max query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: c6232400b39c4564a30a403859ffb4ee
              name: 'DB [{#DBNAME}]: Queries sum query time'
              type: DEPENDENT
              key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: f7099043ea6345f0a5531f70f9573a3e
              name: 'DB [{#DBNAME}]: Queries slow transaction count'
              type: DEPENDENT
              key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
              description: 'Slow transaction query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: c6800ca30a564766ba745e875cb4e929
              name: 'DB [{#DBNAME}]: Queries max transaction time'
              type: DEPENDENT
              key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
              units: s
              description: 'Max transaction query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 0eda974576794768ac9ddc592ff27e19
              name: 'DB [{#DBNAME}]: Queries sum transaction time'
              type: DEPENDENT
              key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum transaction query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: cafcc00cce824c33a321da0e9ecc7f6e
              name: 'DB [{#DBNAME}]: Index scans per second'
              type: DEPENDENT
              key: 'pgsql.scans.idx.rate["{#DBNAME}"]'
              description: 'Number of index scans in the database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.idx
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: scans
                - tag: database
                  value: '{#DBNAME}'
            - uuid: f07396ca9d224e1b819f22efe6c4259d
              name: 'DB [{#DBNAME}]: Sequential scans per second'
              type: DEPENDENT
              key: 'pgsql.scans.seq.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of sequential scans in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.seq
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: scans
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 4bf92e4b0fed4d32b808b299d9e1fb0c
              name: 'DB [{#DBNAME}]: Get scans'
              key: 'pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Number of scans done for table/index in this database.'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
          graph_prototypes:
            - uuid: 3f8124b817f2437096c620d62ec2e055
              name: 'DB [{#DBNAME}]: Block hit/read'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
            - uuid: 6bd0a0d65b8d43ad946b145cf8a8b533
              name: 'DB [{#DBNAME}]: Database size'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.db.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#DBNAME}"]'
            - uuid: 41e765d906324595a396d8985b204ff5
              name: 'DB [{#DBNAME}]: Events'
              ymin_type_1: FIXED
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
            - uuid: 2b260fdf7623476095429434b5c79041
              name: 'DB [{#DBNAME}]: Locks'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.locks.total["{#DBNAME}"]'
            - uuid: 8a60a92b41b146f49145b86bab559b2e
              name: 'DB [{#DBNAME}]: Queries'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
                - sortorder: '3'
                  drawtype: GRADIENT_LINE
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
                - sortorder: '4'
                  drawtype: GRADIENT_LINE
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
                - sortorder: '5'
                  drawtype: GRADIENT_LINE
                  color: 6C59DC
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
            - uuid: 93518b06f71e46ada3dabefa1726b867
              name: 'DB [{#DBNAME}]: Slow queries'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
            - uuid: 779b872280ad46c7a6cdf95c2df7c646
              name: 'DB [{#DBNAME}]: Temp files'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
            - uuid: f10be22e3bac4d66936c34ec99446c64
              name: 'DB [{#DBNAME}]: Tuples'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by Zabbix agent'
                    key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: postgresql
      macros:
        - macro: '{$PG.CACHE_HITRATIO.MIN.WARN}'
          value: '90'
          description: 'Minimum cache hit ratio percentage for trigger expression.'
          config:
            type: TEXT
            priority: '12'
            section_name: Thresholds
            label: 'Minimum cache hit ratio percentage'
            description: 'Minimum cache hit ratio percentage for trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.CHECKPOINTS_REQ.MAX.WARN}'
          value: '5'
          description: 'Maximum required checkpoint occurrences for trigger expression.'
          config:
            type: TEXT
            priority: '13'
            section_name: Thresholds
            label: 'Maximum required checkpoint occurrences'
            description: 'Maximum required checkpoint occurrences for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.CONFLICTS.MAX.WARN}'
          value: '0'
          description: 'Maximum number of recovery conflicts for trigger expression.'
          config:
            type: TEXT
            priority: '17'
            section_name: Thresholds
            label: 'Maximum number of recovery conflicts'
            description: 'Maximum number of recovery conflicts for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.CONN_TOTAL_PCT.MAX.WARN}'
          value: '90'
          description: 'Maximum percentage of current connections for trigger expression.'
          config:
            type: TEXT
            priority: '14'
            section_name: Thresholds
            label: 'Maximum percentage of current connections'
            description: 'Maximum percentage of current connections for trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.DATABASE}'
          value: postgres
          description: 'Default PostgreSQL database for the connection.'
          config:
            type: TEXT
            priority: '5'
            label: 'Default PostgreSQL database for the connection'
            required: 'YES'
        - macro: '{$PG.DEADLOCKS.MAX.WARN}'
          value: '0'
          description: 'Maximum number of detected deadlocks for trigger expression.'
          config:
            type: TEXT
            priority: '15'
            section_name: Thresholds
            label: 'Maximum number of detected deadlocks'
            description: 'Maximum number of detected deadlocks for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.FROZENXID_PCT_STOP.MIN.HIGH}'
          value: '75'
          description: 'Minimum frozen XID before stop percentage for trigger expression.'
          config:
            type: TEXT
            priority: '16'
            section_name: Thresholds
            label: 'Minimum frozen XID before stop percentage'
            description: 'Minimum frozen XID before stop percentage for trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.HOST}'
          value: localhost
          description: 'Hostname or IP of PostgreSQL host.'
          config:
            type: TEXT
            priority: '1'
            label: 'PostgreSQL host'
            description: 'Hostname or IP of PostgreSQL host.'
            required: 'YES'
        - macro: '{$PG.LLD.FILTER.DBNAME}'
          value: .+
          description: 'Filter of discoverable databases.'
          config:
            type: TEXT
            priority: '6'
            section_name: Filters
            label: 'Database name LLD filter'
            description: 'Filter of discoverable databases.'
        - macro: '{$PG.LOCKS.MAX.WARN}'
          value: '100'
          description: 'Maximum number of locks for trigger expression.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Maximum number of locks'
            description: 'Maximum number of locks for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.PASSWORD}'
          type: SECRET_TEXT
          description: 'PostgreSQL user password.'
          config:
            type: TEXT
            priority: '4'
            label: 'PostgreSQL user password'
            required: 'YES'
        - macro: '{$PG.PING_TIME.MAX.WARN}'
          value: 1s
          description: 'Maximum time of connection response for trigger expression.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Maximum time of connection response'
            description: 'Maximum time of connection response for trigger expression.'
        - macro: '{$PG.PORT}'
          value: '5432'
          description: 'PostgreSQL service port.'
          config:
            type: TEXT
            priority: '2'
            label: 'PostgreSQL port'
            description: 'PostgreSQL service port. In the range from 1 to 65535 inclusive.'
            required: 'YES'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.QUERY_ETIME.MAX.WARN}'
          value: '30'
          description: 'Execution time limit for count of slow queries.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Slow queries execution time threshold'
            description: 'Execution time threshold for queries to be considered slow. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.REPL_LAG.MAX.WARN}'
          value: 10m
          description: 'Maximum replication lag time for trigger expression.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'Maximum replication lag time'
            description: 'Maximum replication lag time for trigger expression.'
        - macro: '{$PG.SLOW_QUERIES.MAX.WARN}'
          value: '5'
          description: 'Slow queries count threshold for a trigger.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'Slow queries count threshold'
            description: 'Slow queries count threshold for a trigger. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.USER}'
          value: zbx_monitor
          description: 'PostgreSQL username.'
          config:
            type: TEXT
            priority: '3'
            label: 'PostgreSQL username'
            required: 'YES'
      dashboards:
        - uuid: d95f29826778497a9ed265e0c335fd0f
          name: 'PostgreSQL databases'
          pages:
            - widgets:
                - type: graphprototype
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'DB [{#DBNAME}]: Tuples'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graphprototype
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'DB [{#DBNAME}]: Block hit/read'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graphprototype
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'DB [{#DBNAME}]: Locks'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graphprototype
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'DB [{#DBNAME}]: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graphprototype
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'DB [{#DBNAME}]: Events'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graphprototype
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'DB [{#DBNAME}]: Temp files'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graphprototype
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'DB [{#DBNAME}]: Database size'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graphprototype
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'DB [{#DBNAME}]: Slow queries'
                    - type: STRING
                      name: reference
                      value: AAAAH
        - uuid: f2ceabf59fd64ca9828ea55e9b9668bd
          name: 'PostgreSQL stat'
          pages:
            - widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'PostgreSQL connections'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'PostgreSQL ping'
                    - type: STRING
                      name: reference
                      value: AAAAK
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'PostgreSQL replication lag'
                    - type: STRING
                      name: reference
                      value: AAAAM
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'PostgreSQL bgwriter'
                    - type: STRING
                      name: reference
                      value: AAAAO
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'PostgreSQL transactions'
                    - type: STRING
                      name: reference
                      value: AAAAJ
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'PostgreSQL uptime'
                    - type: STRING
                      name: reference
                      value: AAAAL
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'PostgreSQL WAL'
                    - type: STRING
                      name: reference
                      value: AAAAN
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent'
                        name: 'PostgreSQL checkpoints'
                    - type: STRING
                      name: reference
                      value: AAAAP
      valuemaps:
        - uuid: 2e376ee568d04e7bbe98cbae4181f313
          name: 'PostgreSQL recovery role'
          mappings:
            - value: '0'
              newvalue: Master
            - value: '1'
              newvalue: Standby
        - uuid: 7f553f18ef6544ceaa4b50c4ebf0e583
          name: 'PostgreSQL replication status'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
            - value: '2'
              newvalue: Master
        - uuid: 372bc939f3924aafa13c4821b83a9276
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: d0ef7d659a8f4beaaabfc4b6134e737a
      template: 'PostgreSQL by Zabbix agent 2'
      name: 'PostgreSQL by Zabbix agent 2'
      description: |
        This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent 2 and uses a loadable plugin to run SQL queries.
        
        Setup:
        
        1. Deploy Zabbix agent 2 with the PostgreSQL plugin. Starting with Zabbix versions 6.0.10 / 6.2.4 / 6.4 PostgreSQL metrics are moved to a loadable plugin and require installation of a separate package or compilation of the plugin from sources (https://www.zabbix.com/documentation/7.4/manual/extensions/plugins/build).
        
        2. Create the PostgreSQL user for monitoring (`<password>` at your discretion) and inherit permissions from the default role `pg_monitor`:
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
        GRANT pg_monitor TO zbx_monitor;
        
        3. Edit the `pg_hba.conf` configuration file to allow connections for the user `zbx_monitor`. You can check the PostgreSQL documentation for examples (https://www.postgresql.org/docs/current/auth-pg-hba-conf.html).
        
        4. Set the connection string for the PostgreSQL instance in the `{$PG.CONNSTRING.AGENT2}` macro as URI, such as `<protocol(host:port)>`, or specify the named session - `<sessionname>`.
        
        Note: if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, a named session must be used. In that case, the instance URI should be specified in the `Plugins.PostgreSQL.Sessions.*.Uri` parameter in the PostgreSQL plugin configuration files alongside all the encryption parameters (type, certificate/key filepaths if needed etc.).
        
        You can check the PostgreSQL plugin documentation (https://git.zabbix.com/projects/AP/repos/postgresql/browse?at=refs%2Fheads%2Frelease%2F7.4) for details about agent plugin parameters and named sessions.
        
        Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation (https://www.postgresql.org/docs/current/ssl-tcp.html) for details.
        
        Note that plugin TLS certificate validation relies on checking the Subject Alternative Names (SAN) instead of the Common Name (CN), check the cryptography package documentation (https://pkg.go.dev/crypto/x509) for details.
        
        For example, to enable required encryption in transport mode without identity checks you could create the file `/etc/zabbix/zabbix_agent2.d/postgresql_myconn.conf` with the following configuration for the named session `myconn` (replace `<instanceip>` with the address of the PostgreSQL instance):
        Plugins.PostgreSQL.Sessions.myconn.Uri=tcp://<instanceip>:5432
        Plugins.PostgreSQL.Sessions.myconn.TLSConnect=required
        
        Then set the `{$PG.CONNSTRING.AGENT2}` macro to `myconn` to use this named session.
        
        5. Set the password that you specified in step 2 in the macro `{$PG.PASSWORD}`.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384190-%C2%A0discussion-thread-for-official-zabbix-template-db-postgresql
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Overview
        
        This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent 2 and uses a loadable plugin to run SQL queries.
        
        ## Setup
        
        1. Create the PostgreSQL user for monitoring (`<password>` at your discretion) and inherit permissions from the default role `pg_monitor`:
        
        ```sql
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
        GRANT pg_monitor TO zbx_monitor;
        ```
        
        3. Edit the `pg_hba.conf` configuration file to allow connections for the user `zbx_monitor`. For example, you could add one of the following rows to allow local TCP connections from the same host:
        
        ```bash
        # TYPE  DATABASE        USER            ADDRESS                 METHOD
          host       all        zbx_monitor     localhost               trust
          host       all        zbx_monitor     127.0.0.1/32            md5
          host       all        zbx_monitor     ::1/128                 scram-sha-256
        ```
        
        For more information please read the PostgreSQL documentation `https://www.postgresql.org/docs/current/auth-pg-hba-conf.html`.
        
        4. Set the connection string for the PostgreSQL instance in the `PostgreSQL connection string` host wizard configuration field as URI, such as `<protocol(host:port)>`, or specify the named session - `<sessionname>`.
        
        **Note:** if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, a named session must be used. In that case, the instance URI should be specified in the `Plugins.PostgreSQL.Sessions.*.Uri` parameter in the PostgreSQL plugin configuration files alongside all the encryption parameters (type, certificate/key filepaths if needed etc.).
        
        You can check the [`PostgreSQL plugin documentation`](https://git.zabbix.com/projects/AP/repos/postgresql/browse?at=refs%2Fheads%2Frelease%2F7.4) for details about agent plugin parameters and named sessions.
        
        Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the [`PostgreSQL documentation`](https://www.postgresql.org/docs/current/ssl-tcp.html) for details.
        
        **Note:** plugin TLS certificate validation relies on checking the Subject Alternative Names (SAN) instead of the Common Name (CN), check the cryptography package [`documentation`](https://pkg.go.dev/crypto/x509) for details.
        
        For example, to enable required encryption in transport mode without identity checks you could create the file `/etc/zabbix/zabbix_agent2.d/postgresql_myconn.conf` with the following configuration for the named session `myconn` (replace `<instanceip>` with the address of the PostgreSQL instance):
        
        ```bash
        Plugins.PostgreSQL.Sessions.myconn.Uri=tcp://<instanceip>:5432
        Plugins.PostgreSQL.Sessions.myconn.TLSConnect=required
        ```
        
        Then set the `PostgreSQL connection string` field to `myconn` to use this named session.
        
        5. Set the password that you specified in step 2 in the `PostgreSQL user password` field.
      vendor:
        name: Zabbix
        version: 7.4-3
      groups:
        - name: Templates/Databases
      items:
        - uuid: 04b1c83463f247b0a42f17c5d0a9ce14
          name: 'Archive: Count of archived files'
          type: DEPENDENT
          key: pgsql.archive.count_archived_files
          value_type: FLOAT
          description: 'Count of archived files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.archived_count
          master_item:
            key: 'pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: archive
        - uuid: 729208d50ef64e50b0bb342899e211c2
          name: 'Archive: Count of files in archive_status need to archive'
          type: DEPENDENT
          key: pgsql.archive.count_files_to_archive
          value_type: FLOAT
          description: 'Count of files to archive.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.count_files
          master_item:
            key: 'pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: archive
        - uuid: b60523c62afc4813aeb64cf9598fb7bd
          name: 'Archive: Count of failed attempts to archive files'
          type: DEPENDENT
          key: pgsql.archive.failed_trying_to_archive
          value_type: FLOAT
          description: 'Count of failed attempts to archive files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.failed_count
          master_item:
            key: 'pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: archive
        - uuid: 285f434f79864d24a4e66d5a49c539e9
          name: 'Archive: Size of files need to archive'
          type: DEPENDENT
          key: pgsql.archive.size_files_to_archive
          value_type: FLOAT
          description: 'Size of files to archive.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.size_files
          master_item:
            key: 'pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: archive
        - uuid: e9f4284fd3a1459e9c519dbdd8ee3425
          name: 'Get archive'
          key: 'pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: 'Collect archive status metrics.'
          tags:
            - tag: component
              value: raw
        - uuid: d9169b4b31554063b9d01d0d27b4beee
          name: 'Count of autovacuum workers'
          key: 'pgsql.autovacuum.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          value_type: FLOAT
          description: 'Number of autovacuum workers.'
          tags:
            - tag: component
              value: system
        - uuid: c49f777ae0db48879bc946989bfc36f6
          name: 'Bgwriter: Buffers allocated per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_alloc.rate
          value_type: FLOAT
          description: 'Number of buffers allocated per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_alloc
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 1624e89567824e0493492a3dcc979788
          name: 'Bgwriter: Buffers written directly by a backend per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_backend.rate
          value_type: FLOAT
          description: 'Number of buffers written directly by a backend per second. Available in PostgreSQL versions prior to 17.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_backend
              error_handler: DISCARD_VALUE
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 6e5990d8a0854efd83b3e6a57aa2c2f9
          name: 'Bgwriter: Times a backend executed its own fsync per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_backend_fsync.rate
          value_type: FLOAT
          description: 'Number of times a backend had to execute its own fsync call per second (normally the background writer handles those even when the backend does its own write). Available in PostgreSQL versions prior to 17.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_backend_fsync
              error_handler: DISCARD_VALUE
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 3bf0496d313f4dfea67c95010be54372
          name: 'Checkpoint: Buffers written during checkpoints per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_checkpoint.rate
          value_type: FLOAT
          description: 'Number of buffers written during checkpoints per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_checkpoint
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 65f4aeedbc7d40ed9a14e0dbd8024c4b
          name: 'Checkpoint: Buffers written by the background writer per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_clean.rate
          value_type: FLOAT
          description: 'Number of buffers written by the background writer per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_clean
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 23fcb5ee8c19436b827001114961eb16
          name: 'Checkpoint: Requested per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoints_req.rate
          value_type: FLOAT
          description: 'Number of requested checkpoints that have been performed per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoints_req
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 9c578a8e072940728cc00d94f52cec8d
          name: 'Checkpoint: Scheduled per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoints_timed.rate
          value_type: FLOAT
          description: 'Number of scheduled checkpoints that have been performed per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoints_timed
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: b94507037a584b9391f610e59dd34e6c
          name: 'Checkpoint: Checkpoint sync time per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoint_sync_time.rate
          value_type: FLOAT
          units: s
          description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoint_sync_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 26839587c46043caa2991e973962b954
          name: 'Checkpoint: Checkpoint write time per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoint_write_time.rate
          value_type: FLOAT
          units: s
          description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoint_write_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: b83939ecfb094a7e9eb42cd9a7e2695c
          name: 'Bgwriter: Number of bgwriter cleaning scan stopped per second'
          type: DEPENDENT
          key: pgsql.bgwriter.maxwritten_clean.rate
          value_type: FLOAT
          description: 'Number of times the background writer stopped a cleaning scan because it had written too many buffers per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.maxwritten_clean
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 6020e17c25104cbfba182e9cddfe6336
          name: 'Get bgwriter'
          key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_bgwriter:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: b98d2328694f44598f2177b3f93d4b90
          name: 'Cache hit ratio, %'
          type: CALCULATED
          key: pgsql.cache.hit
          value_type: FLOAT
          units: '%'
          params: 'last(//pgsql.dbstat.sum.blks_hit.rate) * 100 / (last(//pgsql.dbstat.sum.blks_hit.rate) + last(//pgsql.dbstat.sum.blks_read.rate))'
          description: 'Cache hit ratio.'
          tags:
            - tag: component
              value: cache
        - uuid: 2ea55460f0d34063ae4ab65b74ec852c
          name: 'Connections sum: Active'
          type: DEPENDENT
          key: pgsql.connections.sum.active
          description: 'Total number of connections executing a query.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.active
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 69f14028e98b48d489fbd7345c2213dd
          name: 'Connections sum: Disabled'
          type: DEPENDENT
          key: pgsql.connections.sum.disabled
          description: 'Total number of disabled connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.disabled
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 62a2401041724b4888bf058035dc6a0c
          name: 'Connections sum: Fastpath function call'
          type: DEPENDENT
          key: pgsql.connections.sum.fastpath_function_call
          description: 'Total number of connections executing a fast-path function.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.fastpath_function_call
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: fc3b357cc8a24c4aad60784d1bfb7e18
          name: 'Connections sum: Idle'
          type: DEPENDENT
          key: pgsql.connections.sum.idle
          description: 'Total number of connections waiting for a new client command.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: b900a8123dfa48e0ac8fd4b92ae8678d
          name: 'Connections sum: Idle in transaction'
          type: DEPENDENT
          key: pgsql.connections.sum.idle_in_transaction
          description: 'Total number of connections in a transaction state but not executing a query.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle_in_transaction
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 99b0a3e14af44924b0319a0a9f6c16c7
          name: 'Connections sum: Idle in transaction (aborted)'
          type: DEPENDENT
          key: pgsql.connections.sum.idle_in_transaction_aborted
          description: 'Total number of connections in a transaction state but not executing a query, and where one of the statements in the transaction caused an error.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle_in_transaction_aborted
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 194c41f88e9e44879a70033913dd41d3
          name: 'Connections sum: Prepared'
          type: DEPENDENT
          key: pgsql.connections.sum.prepared
          description: |
            Total number of prepared transactions:
            https://www.postgresql.org/docs/current/sql-prepare-transaction.html
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.prepared
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 1ec042e5853b430d9d7982c53c3fcf14
          name: 'Connections sum: Total'
          type: DEPENDENT
          key: pgsql.connections.sum.total
          description: 'Total number of connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 101149dd68994084a1cdab82c9d064f0
          name: 'Connections sum: Total, %'
          type: DEPENDENT
          key: pgsql.connections.sum.total_pct
          units: '%'
          description: 'Total number of connections, in percentage.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total_pct
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: 1d0903401af64d93ac16761808d672ca
              expression: 'min(/PostgreSQL by Zabbix agent 2/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN}'
              name: 'PostgreSQL: Total number of connections is too high'
              event_name: 'PostgreSQL: Total number of connections is too high (over {$PG.CONN_TOTAL_PCT.MAX.WARN} in 5m)'
              priority: AVERAGE
              description: 'Total number of current connections exceeds the limit of {$PG.CONN_TOTAL_PCT.MAX.WARN}% out of the maximum number of concurrent connections to the database server (the "max_connections" setting).'
              tags:
                - tag: scope
                  value: performance
        - uuid: f2c298008b914434b96da85a985e4a54
          name: 'Connections sum: Waiting'
          type: DEPENDENT
          key: pgsql.connections.sum.waiting
          description: |
            Total number of waiting connections:
            https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.waiting
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: e926ecd967f342bf90e9923825147d64
          name: 'Get connections sum'
          key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_activity:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: 1cab825fac8a49ba96dfbf7a696be729
          name: 'Custom queries'
          key: 'pgsql.custom.query["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}",""]'
          history: 1h
          value_type: TEXT
          status: DISABLED
          description: 'Execute custom queries from file *.sql (check for option Plugins.Postgres.CustomQueriesPath at agent configuration).'
          tags:
            - tag: component
              value: application
        - uuid: 5c6de0fe332043bfb35c999b10893e4c
          name: 'Dbstat: Hit blocks read per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blks_hit.rate
          value_type: FLOAT
          description: 'Number of times per second disk blocks were found already in the buffer cache'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blks_hit
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 4dc3f2c23dfd4dfebe024a5c2d4409ae
          name: 'Dbstat: Disk blocks read per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blks_read.rate
          value_type: FLOAT
          description: 'Number of disk blocks read per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blks_read
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: storage
        - uuid: 619211cc2afa4a159f36abf1a17d5476
          name: 'Dbstat: Blocks read time'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blk_read_time
          value_type: FLOAT
          units: s
          description: 'Time spent reading data file blocks by backends.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blk_read_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: storage
        - uuid: fba3b51d644c4c16ac71b3eda1be1701
          name: 'Dbstat: Blocks write time'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blk_write_time
          value_type: FLOAT
          units: s
          description: 'Time spent writing data file blocks by backends.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blk_write_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: storage
        - uuid: 1b98b9c95b32424baa68c354496ed2de
          name: 'Dbstat: Checksum failures per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.checksum_failures.rate
          value_type: FLOAT
          description: 'Number of data page checksum failures per second detected (or on a shared object), or NULL if data checksums are not enabled. This metric is available since PostgreSQL 12.'
          valuemap:
            name: 'PostgreSQL checksum failure status'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checksum_failures
            - type: MATCHES_REGEX
              parameters:
                - '^\d*$'
              error_handler: CUSTOM_VALUE
              error_handler_params: '-2'
            - type: CHANGE_PER_SECOND
              error_handler: CUSTOM_VALUE
              error_handler_params: '-1'
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: 1d67b13f47134a538708c2a14dcfa6b1
              expression: 'last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.sum.checksum_failures.rate)>0'
              name: 'PostgreSQL: Dbstat: Checksum failures detected'
              priority: AVERAGE
              description: |
                Data page checksum failures were detected on that DB instance:
                https://www.postgresql.org/docs/current/checksums.html
              tags:
                - tag: scope
                  value: availability
        - uuid: 0106dfc55ace4dacaff00ce2c98de2ea
          name: 'Dbstat: Conflicts per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.conflicts.rate
          value_type: FLOAT
          description: 'Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.conflicts
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: e5d3838e5cf84be9ae83cacf22dc99af
          name: 'Dbstat: Deadlocks per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.deadlocks.rate
          value_type: FLOAT
          description: 'Number of deadlocks detected per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.deadlocks
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: deadlocks
        - uuid: c61f60e6f7d24ffe99db480f6bbd9613
          name: 'Dbstat: Backends connected'
          type: DEPENDENT
          key: pgsql.dbstat.sum.numbackends
          description: 'Number of connected backends.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.numbackends
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: backends
        - uuid: 96cb6b388b2c480ead1568293dd81e70
          name: 'Dbstat: Number temp bytes per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.temp_bytes.rate
          value_type: FLOAT
          units: b
          description: 'Total amount of data written per second to temporary files by queries.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.temp_bytes
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: storage
        - uuid: bea47c8a95074ad3997aff64fcfcf49b
          name: 'Dbstat: Number temp files per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.temp_files.rate
          value_type: FLOAT
          description: 'Number of temporary files created by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.temp_files
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: storage
        - uuid: 731f4adac9d34eaaaa1f8d5080fdf6ce
          name: 'Dbstat: Rows deleted per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_deleted.rate
          value_type: FLOAT
          description: 'Number of rows deleted by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_deleted
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 4eb6cc273484453bab1233de085363f5
          name: 'Dbstat: Rows fetched per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_fetched.rate
          value_type: FLOAT
          description: 'Number of rows fetched by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_fetched
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: ae250ffa30c94df187c2010011e794aa
          name: 'Dbstat: Rows inserted per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_inserted.rate
          value_type: FLOAT
          description: 'Number of rows inserted by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_inserted
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 3253ed1c96db4a84974e62b85d80bc0f
          name: 'Dbstat: Rows returned per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_returned.rate
          value_type: FLOAT
          description: 'Number of rows returned by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_returned
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 13feadafa00a4bd293fcf1a98ddf1f39
          name: 'Dbstat: Rows updated per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_updated.rate
          value_type: FLOAT
          description: 'Number of rows updated by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_updated
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: bc8a3b29a6684b7f8a70a54b962f0e7e
          name: 'Dbstat: Committed transactions per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.xact_commit.rate
          value_type: FLOAT
          description: 'Number of transactions that have been committed per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.xact_commit
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: 8aedfe3e385b447eb75b85f92301665a
          name: 'Dbstat: Roll backed transactions per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.xact_rollback.rate
          value_type: FLOAT
          description: 'Number of transactions that have been rolled back per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.xact_rollback
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: ddddde3084d54f55838b970f44290523
          name: 'Get dbstat sum'
          key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_database as sums for all databases:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: 3be06ec14cba44d0892f3271a599c473
          name: 'Get dbstat'
          key: 'pgsql.dbstat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_database per database:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: 7112eeb300c14d959c79715462bf9563
          name: 'Get locks'
          key: 'pgsql.locks["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_locks per database:
            https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES
          tags:
            - tag: component
              value: raw
        - uuid: 0377fe6f2f8d4539b649c636ab012415
          name: 'Age of oldest xid'
          key: 'pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          value_type: FLOAT
          description: 'Age of oldest xid.'
          tags:
            - tag: component
              value: transactions
          triggers:
            - uuid: 2a5c11571d9d46f093ed9081f9d51504
              expression: 'last(/PostgreSQL by Zabbix agent 2/pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) > 18000000'
              name: 'PostgreSQL: Oldest xid is too big'
              priority: AVERAGE
              tags:
                - tag: scope
                  value: availability
        - uuid: 56323e572fa443228987c62039153825
          name: Ping
          key: 'pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: 48a24a78519d47349200f0b41ceec56a
              expression: 'last(/PostgreSQL by Zabbix agent 2/pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"])=0'
              name: 'PostgreSQL: Service is down'
              priority: HIGH
              description: 'Last test of a connection was unsuccessful.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 01123126fcd54adc84c3bbfa227d9c0c
          name: 'Get queries'
          key: 'pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"]'
          history: '0'
          value_type: TEXT
          description: 'Collect all metrics by query execution time.'
          tags:
            - tag: component
              value: raw
        - uuid: a171db459d6144e4ad294579fb8dc56d
          name: 'Replication: Standby count'
          key: 'pgsql.replication.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Number of standby servers.'
          tags:
            - tag: component
              value: replication
        - uuid: da9ce769f9444a3f9600ce64c4ab2857
          name: 'Replication: Lag in bytes'
          key: 'pgsql.replication.lag.b["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          units: B
          description: 'Replication lag with master, in bytes.'
          tags:
            - tag: component
              value: replication
        - uuid: 5a9eb8ee4a484911903688e620eb618b
          name: 'Replication: Lag in seconds'
          key: 'pgsql.replication.lag.sec["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          units: s
          description: 'Replication lag with master, in seconds.'
          tags:
            - tag: component
              value: replication
        - uuid: 4120befb754d47e9a931f868c28badb9
          name: 'Get replication'
          key: 'pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: 'Collect metrics from the pg_stat_replication, which contains information about the WAL sender process, showing statistics about replication to that sender''s connected standby server.'
          tags:
            - tag: component
              value: raw
        - uuid: 4085b836bf614f3d910818074c386845
          name: 'Replication: Recovery role'
          key: 'pgsql.replication.recovery_role["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode.'
          valuemap:
            name: 'PostgreSQL recovery role'
          tags:
            - tag: component
              value: replication
        - uuid: 3c83904cbad74ff7a0d10136a233e6c6
          name: 'Replication: Status'
          key: 'pgsql.replication.status["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode.'
          valuemap:
            name: 'PostgreSQL replication status'
          tags:
            - tag: component
              value: replication
        - uuid: efa946a67e5844ecb905c68a2a6b85bb
          name: Uptime
          key: 'pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          value_type: FLOAT
          units: uptime
          description: 'Time since the server started.'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 5fbabc5f60b74a369a13a260d25cce3c
              expression: 'last(/PostgreSQL by Zabbix agent 2/pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m'
              name: 'PostgreSQL: Service has been restarted'
              event_name: 'PostgreSQL: Service has been restarted (uptime < 10m)'
              priority: AVERAGE
              description: 'PostgreSQL uptime is less than 10 minutes.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 523528aad175455fbd1daba161365651
          name: Version
          key: 'pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 15m
          value_type: CHAR
          description: 'PostgreSQL version.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 6b3ac2a19e114e1390e6e0793728f576
              expression: 'last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent 2/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0'
              name: 'PostgreSQL: Version has changed'
              event_name: 'PostgreSQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              tags:
                - tag: scope
                  value: notice
        - uuid: 6d5aa6213cf248749cbffdea9aff694f
          name: 'WAL: Segments count'
          type: DEPENDENT
          key: pgsql.wal.count
          description: 'Number of WAL segments.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.count
          master_item:
            key: 'pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: wal
        - uuid: 0e58a74b8a2d47d28f596196405b22b5
          name: 'WAL: Bytes received'
          type: DEPENDENT
          key: pgsql.wal.receive
          units: B
          description: 'WAL receive, in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.receive
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: wal
        - uuid: c3d96741af454f6b9a3a49b6117c31be
          name: 'Get WAL'
          key: 'pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 5m
          history: '0'
          value_type: TEXT
          description: 'Collect write-ahead log (WAL) metrics.'
          tags:
            - tag: component
              value: raw
        - uuid: 95f67516be544daf9ad8a1cad2e46114
          name: 'WAL: Bytes written'
          type: DEPENDENT
          key: pgsql.wal.write
          units: B
          description: 'WAL write, in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.write
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: wal
      discovery_rules:
        - uuid: b1a4bfe1031a40529a7c38ac6bed3c6d
          name: 'Database discovery'
          key: 'pgsql.db.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 1h
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DBNAME}'
                value: '{$PG.LLD.FILTER.DBNAME}'
          description: |
            Discovers databases (DB) in the database management system (DBMS), except:
            - templates;
            - DBs that do not allow connections.
          item_prototypes:
            - uuid: 1419ff1331734a4088349332e118ca94
              name: 'DB [{#DBNAME}]: Database age'
              key: 'pgsql.db.age["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              delay: 10m
              description: 'Database age.'
              tags:
                - tag: component
                  value: application
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 4367ba7fdffd459ea2b18e1877bc74ca
              name: 'DB [{#DBNAME}]: Bloating tables'
              key: 'pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              description: 'Number of bloating tables.'
              tags:
                - tag: component
                  value: tables
                - tag: database
                  value: '{#DBNAME}'
            - uuid: b614a0909eec40bc841bf7446e842544
              name: 'DB [{#DBNAME}]: Database size'
              key: 'pgsql.db.size["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              delay: 5m
              units: B
              description: 'Database size.'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 4b1b1a4374c0429cb1790e774f181512
              name: 'DB [{#DBNAME}]: Blocks hit per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blks_hit
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: cache
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 841496e662cc43cf8db7728e96fcba76
              name: 'DB [{#DBNAME}]: Disk blocks read per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of disk blocks read per second in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blks_read
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 0313d02ce8274bc9bcaee54d062300c8
              name: 'DB [{#DBNAME}]: Disk blocks read time per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blk_read_time.rate["{#DBNAME}"]'
              value_type: FLOAT
              units: s
              description: 'Time spent reading data file blocks by backends per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blk_read_time
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: e746a7760d554a0e9d41ba01c3be9db5
              name: 'DB [{#DBNAME}]: Disk blocks write time'
              type: DEPENDENT
              key: 'pgsql.dbstat.blk_write_time.rate["{#DBNAME}"]'
              value_type: FLOAT
              units: s
              description: 'Time spent writing data file blocks by backends per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blk_write_time
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: d44335162082498bbc42e29e938a4de7
              name: 'DB [{#DBNAME}]: Checksum failures'
              type: DEPENDENT
              key: 'pgsql.dbstat.checksum_failures.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of data page checksum failures detected in this database.'
              valuemap:
                name: 'PostgreSQL checksum failure status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.checksum_failures
                - type: MATCHES_REGEX
                  parameters:
                    - '^\d*$'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '-2'
                - type: CHANGE_PER_SECOND
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '-1'
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: system
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 5995403b904349d296227647ca318f5b
                  expression: 'last(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.checksum_failures.rate["{#DBNAME}"])>0'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Checksum failures detected'
                  priority: AVERAGE
                  description: |
                    Data page checksum failures were detected on that database:
                    https://www.postgresql.org/docs/current/checksums.html
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 4eb67f16bc2948a7927ed58c9d037466
              name: 'DB [{#DBNAME}]: Detected conflicts per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of queries canceled due to conflicts with recovery in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.conflicts
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 05ac4216e1a941df8880224ffd38b806
                  expression: 'min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts (over {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: AVERAGE
                  description: |
                    The primary and standby servers are in many ways loosely connected. Actions on the primary will have an effect on the standby. As a result, there is potential for negative interactions or conflicts between them.
                    https://www.postgresql.org/docs/current/hot-standby.html#HOT-STANDBY-CONFLICT
                  tags:
                    - tag: scope
                      value: performance
            - uuid: d53da0cc702f4fe381e4d13d454ec229
              name: 'DB [{#DBNAME}]: Detected deadlocks per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of detected deadlocks in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.deadlocks
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: deadlocks
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: dd948e3ec19c419e8c9a62ace8d1695f
                  expression: 'min(/PostgreSQL by Zabbix agent 2/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Deadlock occurred'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Deadlock occurred (over {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: HIGH
                  description: 'Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m.'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 7ebf1570bebe4b9cb82474fe5aea0562
              name: 'DB [{#DBNAME}]: Get dbstat'
              type: DEPENDENT
              key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get dbstat metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.dbstat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 2e31986867d24bca930d141cc5d9cc0f
              name: 'DB [{#DBNAME}]: Backends connected'
              type: DEPENDENT
              key: 'pgsql.dbstat.numbackends["{#DBNAME}"]'
              description: 'Number of backends currently connected to this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.numbackends
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: backends
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 82a2f4b2dc4f4dfe9a0a42144f603a8a
              name: 'DB [{#DBNAME}]: Temp_bytes written per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
              units: B
              description: 'Total amount of data written to temporary files by queries in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.temp_bytes
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 480ffc23ca8d41e3ac86bb162007065f
              name: 'DB [{#DBNAME}]: Temp_files created per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
              description: 'Total number of temporary files created by queries in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.temp_files
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: cf288751fb894e5291b2d539b4c1a6a1
              name: 'DB [{#DBNAME}]: Tuples deleted per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows deleted by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_deleted
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: a512a7a075244ccb90ab6824125a405e
              name: 'DB [{#DBNAME}]: Tuples fetched per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows fetched by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_fetched
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 2f24c195df5842f1bdf65a11dea3a315
              name: 'DB [{#DBNAME}]: Tuples inserted per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows inserted by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_inserted
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 175c5051ef0c4a31b76270cacbdd7ed5
              name: 'DB [{#DBNAME}]: Tuples returned per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of rows returned by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_returned
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 9888b495d3f04cceb373c341bd4f1941
              name: 'DB [{#DBNAME}]: Tuples updated per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows updated by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_updated
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 5b0ecb9c928c49a6a01b5df6aec931dd
              name: 'DB [{#DBNAME}]: Commits per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of transactions in this database that have been committed per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.xact_commit
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 1d280198e31649fcb053d4c87a0e869d
              name: 'DB [{#DBNAME}]: Rollbacks per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of transactions in this database that have been rolled back.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.xact_rollback
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 8eb2bd907a0e4385bcac9e0f467f9748
              name: 'DB [{#DBNAME}]: Num of accessexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.accessexclusive["{#DBNAME}"]'
              description: 'Number of accessexclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.accessexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 5f783de0d6124fc0ae14522a4ad89189
              name: 'DB [{#DBNAME}]: Num of accessshare locks'
              type: DEPENDENT
              key: 'pgsql.locks.accessshare["{#DBNAME}"]'
              description: 'Number of accessshare locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.accessshare
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 3c754430815f411e9aa8dde593f6333a
              name: 'DB [{#DBNAME}]: Num of exclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.exclusive["{#DBNAME}"]'
              description: 'Number of exclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.exclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 2c7759f4c9e442cb80bd54ea3323501b
              name: 'DB [{#DBNAME}]: Get locks'
              type: DEPENDENT
              key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get locks metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.locks["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: b1ccea7698264d768da1299ec9d13738
              name: 'DB [{#DBNAME}]: Num of rowexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.rowexclusive["{#DBNAME}"]'
              description: 'Number of rowexclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rowexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: b4b1402b99284f3bbf0ac0dff493449f
              name: 'DB [{#DBNAME}]: Num of rowshare locks'
              type: DEPENDENT
              key: 'pgsql.locks.rowshare["{#DBNAME}"]'
              description: 'Number of rowshare locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rowshare
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 15eb93e90c1241a99aaff834d69cc5be
              name: 'DB [{#DBNAME}]: Num of sharerowexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.sharerowexclusive["{#DBNAME}"]'
              description: 'Number of total sharerowexclusive for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.sharerowexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 04e6cec0423f4dddb09e6643561bdf77
              name: 'DB [{#DBNAME}]: Num of shareupdateexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.shareupdateexclusive["{#DBNAME}"]'
              description: 'Number of shareupdateexclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.shareupdateexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 8a410cf1f0be41fbb5a976f368f07430
              name: 'DB [{#DBNAME}]: Num of share locks'
              type: DEPENDENT
              key: 'pgsql.locks.share["{#DBNAME}"]'
              description: 'Number of share locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.share
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: a982064d710644db85ebc1cde67bfe4d
              name: 'DB [{#DBNAME}]: Num of locks total'
              type: DEPENDENT
              key: 'pgsql.locks.total["{#DBNAME}"]'
              description: 'Total number of locks in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.total
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 75e704af5cb545fd9f83bec3f147dd04
              name: 'DB [{#DBNAME}]: Get queries'
              type: DEPENDENT
              key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get queries metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 4c8934820b7f46a195115c7214d4379c
              name: 'DB [{#DBNAME}]: Queries slow maintenance count'
              type: DEPENDENT
              key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
              description: 'Slow maintenance query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 612c8f83e228406f86e70e8486a51f9b
              name: 'DB [{#DBNAME}]: Queries max maintenance time'
              type: DEPENDENT
              key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
              units: s
              description: 'Max maintenance query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 9cde2701b5814142b064696dc974f45d
              name: 'DB [{#DBNAME}]: Queries sum maintenance time'
              type: DEPENDENT
              key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum maintenance query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 9e1191f80c3a4e9aa0d3aba2b2740fef
              name: 'DB [{#DBNAME}]: Queries slow query count'
              type: DEPENDENT
              key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
              description: 'Slow query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 2bb34a2a7dee451cb5419a146d883601
                  expression: 'min(/PostgreSQL by Zabbix agent 2/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Too many slow queries'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Too many slow queries (over {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: WARNING
                  description: 'The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}.'
                  tags:
                    - tag: scope
                      value: performance
            - uuid: 73712df30d66494998bf11566eba409f
              name: 'DB [{#DBNAME}]: Queries max query time'
              type: DEPENDENT
              key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
              units: s
              description: 'Max query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: ba95d84bc11b4df4aece8ddb51042339
              name: 'DB [{#DBNAME}]: Queries sum query time'
              type: DEPENDENT
              key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: d31701d52f5941d5a24241c95db52373
              name: 'DB [{#DBNAME}]: Queries slow transaction count'
              type: DEPENDENT
              key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
              description: 'Slow transaction query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: ecc24b3143254dd4b2fc01c12cefb345
              name: 'DB [{#DBNAME}]: Queries max transaction time'
              type: DEPENDENT
              key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
              units: s
              description: 'Max transaction query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 178926a753614bb58206d82f68280097
              name: 'DB [{#DBNAME}]: Queries sum transaction time'
              type: DEPENDENT
              key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum transaction query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
          graph_prototypes:
            - uuid: af6eac83efc94d2a9f4a3501207fb5ce
              name: 'DB [{#DBNAME}]: Locks'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.locks.total["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.locks.accessexclusive["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.locks.accessshare["{#DBNAME}"]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.locks.exclusive["{#DBNAME}"]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.locks.rowexclusive["{#DBNAME}"]'
                - sortorder: '5'
                  color: 6C59DC
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.locks.rowshare["{#DBNAME}"]'
                - sortorder: '6'
                  color: C7A72D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.locks.sharerowexclusive["{#DBNAME}"]'
                - sortorder: '7'
                  color: BA2A5D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.locks.shareupdateexclusive["{#DBNAME}"]'
                - sortorder: '8'
                  color: F230E0
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.locks.share["{#DBNAME}"]'
            - uuid: 9a518b4bf0f04609863bf9dc4c7f1ea2
              name: 'DB [{#DBNAME}]: Number of bloating tables'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
            - uuid: 4d46d39a1d1146c19a57b2b5b8086708
              name: 'DB [{#DBNAME}]: pg_stat_database metrics'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
                - sortorder: '5'
                  color: 6C59DC
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
                - sortorder: '6'
                  color: C7A72D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
                - sortorder: '7'
                  color: BA2A5D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
                - sortorder: '8'
                  color: F230E0
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
                - sortorder: '9'
                  color: 5CCD18
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
                - sortorder: '10'
                  color: BB2A02
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
                - sortorder: '11'
                  color: AC41A5
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
                - sortorder: '12'
                  color: 89ABF8
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
            - uuid: 98f4c88e15b742fb80e1ecd8aeab970d
              name: 'DB [{#DBNAME}]: Queries'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
                - sortorder: '3'
                  drawtype: GRADIENT_LINE
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
                - sortorder: '4'
                  drawtype: GRADIENT_LINE
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
                - sortorder: '5'
                  drawtype: GRADIENT_LINE
                  color: 6C59DC
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
            - uuid: 86853d8590344bad84aab1deb3d1cffc
              name: 'DB [{#DBNAME}]: Size'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.db.size["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
            - uuid: 918a6fd8bd0e49c98f759778f44ab606
              name: 'DB [{#DBNAME}]: Slow queries'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
        - uuid: e94f9017c06644a2bbcb48697381556d
          name: 'Replication discovery'
          key: 'pgsql.replication.process.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 15m
          filter:
            evaltype: AND
            conditions:
              - macro: '{#APPLICATION_NAME}'
                value: '{$PG.LLD.FILTER.APPLICATION}'
          description: 'Discovers replication lag metrics.'
          item_prototypes:
            - uuid: a77e5e6702ff41af9defe102cbeeea74
              name: 'Application [{#APPLICATION_NAME}]: Get replication'
              type: DEPENDENT
              key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Collect metrics from the "pg_stat_replication" about the application "{#APPLICATION_NAME}" that is connected to this WAL sender, which contains information about the WAL sender process, showing statistics about replication to that sender''s connected standby server.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#APPLICATION_NAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: raw
            - uuid: 15b83330044042668e618501160c37e4
              name: 'Application [{#APPLICATION_NAME}]: Replication flush lag'
              type: DEPENDENT
              key: 'pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"]'
              value_type: FLOAT
              units: s
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.flush_lag
              master_item:
                key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: replication
            - uuid: 0daf6e3c7843488cb3160a2bd6b09fbf
              name: 'Application [{#APPLICATION_NAME}]: Replication replay lag'
              type: DEPENDENT
              key: 'pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"]'
              value_type: FLOAT
              units: s
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.replay_lag
              master_item:
                key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: replication
            - uuid: 2d96bc517d3a4c3fbcae8a7f1436bf72
              name: 'Application [{#APPLICATION_NAME}]: Replication write lag'
              type: DEPENDENT
              key: 'pgsql.replication.process.write_lag["{#APPLICATION_NAME}"]'
              value_type: FLOAT
              units: s
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.write_lag
              master_item:
                key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: replication
          graph_prototypes:
            - uuid: e79dfe2d436d49da898772a9e7345825
              name: 'Application [{#APPLICATION_NAME}]: Replication lag'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent 2'
                    key: 'pgsql.replication.process.write_lag["{#APPLICATION_NAME}"]'
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: postgresql
      macros:
        - macro: '{$PG.CONFLICTS.MAX.WARN}'
          value: '0'
          description: 'Maximum number of recovery conflicts for trigger expression.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Maximum number of recovery conflicts'
            description: 'Maximum number of recovery conflicts for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.CONNSTRING.AGENT2}'
          value: 'tcp://localhost:5432'
          description: 'URI or named session of the PostgreSQL instance.'
          config:
            type: TEXT
            priority: '1'
            label: 'PostgreSQL connection string'
            description: 'URI or named session of the PostgreSQL instance.'
            required: 'YES'
        - macro: '{$PG.CONN_TOTAL_PCT.MAX.WARN}'
          value: '90'
          description: 'Maximum percentage of current connections for trigger expression.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Maximum percentage of current connections'
            description: 'Maximum percentage of current connections for trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.DATABASE}'
          value: postgres
          description: 'Default PostgreSQL database for the connection.'
          config:
            type: TEXT
            priority: '4'
            label: 'Default PostgreSQL database for the connection'
            required: 'YES'
        - macro: '{$PG.DEADLOCKS.MAX.WARN}'
          value: '0'
          description: 'Maximum number of detected deadlocks for trigger expression.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Maximum number of detected deadlocks'
            description: 'Maximum number of detected deadlocks for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.LLD.FILTER.APPLICATION}'
          value: .+
          description: 'Filter of discoverable applications.'
          config:
            type: TEXT
            priority: '6'
            section_name: Filters
            label: 'Applications LLD filter'
            description: 'Filter of discoverable applications.'
        - macro: '{$PG.LLD.FILTER.DBNAME}'
          value: .+
          description: 'Filter of discoverable databases.'
          config:
            type: TEXT
            priority: '5'
            section_name: Filters
            label: 'Database name LLD filter'
            description: 'Filter of discoverable databases.'
        - macro: '{$PG.PASSWORD}'
          type: SECRET_TEXT
          description: 'PostgreSQL user password.'
          config:
            type: TEXT
            priority: '3'
            label: 'PostgreSQL user password'
            required: 'YES'
        - macro: '{$PG.QUERY_ETIME.MAX.WARN}'
          value: '30'
          description: 'Execution time limit for count of slow queries.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'Slow queries execution time threshold'
            description: 'Execution time threshold for queries to be considered slow. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.SLOW_QUERIES.MAX.WARN}'
          value: '5'
          description: 'Slow queries count threshold for a trigger.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'Slow queries count threshold'
            description: 'Slow queries count threshold for a trigger. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.USER}'
          value: zbx_monitor
          description: 'PostgreSQL username.'
          config:
            type: TEXT
            priority: '2'
            label: 'PostgreSQL username'
            required: 'YES'
      dashboards:
        - uuid: e3ae726b06cc4663a3eef5a73909f796
          name: 'PostgreSQL databases'
          pages:
            - widgets:
                - type: graphprototype
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2'
                        name: 'DB [{#DBNAME}]: pg_stat_database metrics'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graphprototype
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2'
                        name: 'DB [{#DBNAME}]: Size'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graphprototype
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2'
                        name: 'DB [{#DBNAME}]: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graphprototype
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2'
                        name: 'DB [{#DBNAME}]: Locks'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graphprototype
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2'
                        name: 'DB [{#DBNAME}]: Number of bloating tables'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graphprototype
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2'
                        name: 'DB [{#DBNAME}]: Slow queries'
                    - type: STRING
                      name: reference
                      value: AAAAF
      valuemaps:
        - uuid: cd2d975b0d7e4f8e89afb1033fce4ce2
          name: 'PostgreSQL checksum failure status'
          mappings:
            - value: '-2'
              newvalue: 'null'
        - uuid: 9f38c01c325248d4b538c0582432b541
          name: 'PostgreSQL recovery role'
          mappings:
            - value: '0'
              newvalue: Master
            - value: '1'
              newvalue: Standby
        - uuid: 0fba38eefa4c4073b46d3f8579fda314
          name: 'PostgreSQL replication status'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
            - value: '2'
              newvalue: Master
        - uuid: 6619a58602a44e83950d3d4b5180c0e9
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: 21cca24cec1d40cdb0c2999aa6ac3037
      template: 'PostgreSQL by Zabbix agent 2 active'
      name: 'PostgreSQL by Zabbix agent 2 active'
      description: |
        This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent 2 and uses a loadable plugin to run SQL queries.
        
        Setup:
        
        1. Deploy Zabbix agent 2 with the PostgreSQL plugin. Starting with Zabbix versions 6.0.10 / 6.2.4 / 6.4 PostgreSQL metrics are moved to a loadable plugin and require installation of a separate package or compilation of the plugin from sources (https://www.zabbix.com/documentation/7.4/manual/extensions/plugins/build).
        
        2. Create the PostgreSQL user for monitoring (`<password>` at your discretion) and inherit permissions from the default role `pg_monitor`:
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
        GRANT pg_monitor TO zbx_monitor;
        
        3. Edit the `pg_hba.conf` configuration file to allow connections for the user `zbx_monitor`. You can check the PostgreSQL documentation for examples (https://www.postgresql.org/docs/current/auth-pg-hba-conf.html).
        
        4. Set the connection string for the PostgreSQL instance in the `{$PG.CONNSTRING.AGENT2}` macro as URI, such as `<protocol(host:port)>`, or specify the named session - `<sessionname>`.
        
        Note: if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, a named session must be used. In that case, the instance URI should be specified in the `Plugins.PostgreSQL.Sessions.*.Uri` parameter in the PostgreSQL plugin configuration files alongside all the encryption parameters (type, certificate/key filepaths if needed etc.).
        
        You can check the PostgreSQL plugin documentation (https://git.zabbix.com/projects/AP/repos/postgresql/browse?at=refs%2Fheads%2Frelease%2F7.4) for details about agent plugin parameters and named sessions.
        
        Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation (https://www.postgresql.org/docs/current/ssl-tcp.html) for details.
        
        Note that plugin TLS certificate validation relies on checking the Subject Alternative Names (SAN) instead of the Common Name (CN), check the cryptography package documentation (https://pkg.go.dev/crypto/x509) for details.
        
        For example, to enable required encryption in transport mode without identity checks you could create the file `/etc/zabbix/zabbix_agent2.d/postgresql_myconn.conf` with the following configuration for the named session `myconn` (replace `<instanceip>` with the address of the PostgreSQL instance):
        Plugins.PostgreSQL.Sessions.myconn.Uri=tcp://<instanceip>:5432
        Plugins.PostgreSQL.Sessions.myconn.TLSConnect=required
        
        Then set the `{$PG.CONNSTRING.AGENT2}` macro to `myconn` to use this named session.
        
        5. Set the password that you specified in step 2 in the macro `{$PG.PASSWORD}`.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384190-%C2%A0discussion-thread-for-official-zabbix-template-db-postgresql
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Overview
        
        This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent 2 and uses a loadable plugin to run SQL queries.
        
        ## Setup
        
        1. Create the PostgreSQL user for monitoring (`<password>` at your discretion) and inherit permissions from the default role `pg_monitor`:
        
        ```sql
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
        GRANT pg_monitor TO zbx_monitor;
        ```
        
        2. Edit the `pg_hba.conf` configuration file to allow connections for the user `zbx_monitor`. For example, you could add one of the following rows to allow local TCP connections from the same host:
        
        ```bash
        # TYPE  DATABASE        USER            ADDRESS                 METHOD
          host       all        zbx_monitor     localhost               trust
          host       all        zbx_monitor     127.0.0.1/32            md5
          host       all        zbx_monitor     ::1/128                 scram-sha-256
        ```
        
        For more information please read the PostgreSQL documentation `https://www.postgresql.org/docs/current/auth-pg-hba-conf.html`.
        
        3. Set the connection string for the PostgreSQL instance in the `PostgreSQL connection string` host wizard configuration field as URI, such as `<protocol(host:port)>`, or specify the named session - `<sessionname>`.
        
        **Note:** if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, a named session must be used. In that case, the instance URI should be specified in the `Plugins.PostgreSQL.Sessions.*.Uri` parameter in the PostgreSQL plugin configuration files alongside all the encryption parameters (type, certificate/key filepaths if needed etc.).
        
        You can check the [`PostgreSQL plugin documentation`](https://git.zabbix.com/projects/AP/repos/postgresql/browse?at=refs%2Fheads%2Frelease%2F7.4) for details about agent plugin parameters and named sessions.
        
        Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the [`PostgreSQL documentation`](https://www.postgresql.org/docs/current/ssl-tcp.html) for details.
        
        **Note:** plugin TLS certificate validation relies on checking the Subject Alternative Names (SAN) instead of the Common Name (CN), check the cryptography package [`documentation`](https://pkg.go.dev/crypto/x509) for details.
        
        For example, to enable required encryption in transport mode without identity checks you could create the file `/etc/zabbix/zabbix_agent2.d/postgresql_myconn.conf` with the following configuration for the named session `myconn` (replace `<instanceip>` with the address of the PostgreSQL instance):
        
        ```bash
        Plugins.PostgreSQL.Sessions.myconn.Uri=tcp://<instanceip>:5432
        Plugins.PostgreSQL.Sessions.myconn.TLSConnect=required
        ```
        
        Then set the `PostgreSQL connection string` field to `myconn` to use this named session.
        
        4. Set the password that you specified in step 2 in the `PostgreSQL user password` field.
      vendor:
        name: Zabbix
        version: 7.4-3
      groups:
        - name: Templates/Databases
      items:
        - uuid: b760f7ff059e40d7ab9d26fe5cc3fa2d
          name: 'Archive: Count of archived files'
          type: DEPENDENT
          key: pgsql.archive.count_archived_files
          value_type: FLOAT
          description: 'Count of archived files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.archived_count
          master_item:
            key: 'pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: archive
        - uuid: 8d7aee551783484d9a321a5e7d57c417
          name: 'Archive: Count of files in archive_status need to archive'
          type: DEPENDENT
          key: pgsql.archive.count_files_to_archive
          value_type: FLOAT
          description: 'Count of files to archive.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.count_files
          master_item:
            key: 'pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: archive
        - uuid: 99ada32d0c2f4241bc81a09b0226b661
          name: 'Archive: Count of failed attempts to archive files'
          type: DEPENDENT
          key: pgsql.archive.failed_trying_to_archive
          value_type: FLOAT
          description: 'Count of failed attempts to archive files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.failed_count
          master_item:
            key: 'pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: archive
        - uuid: 842a4e56976a4dcbb41b388bfb3798ea
          name: 'Archive: Size of files need to archive'
          type: DEPENDENT
          key: pgsql.archive.size_files_to_archive
          value_type: FLOAT
          description: 'Size of files to archive.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.size_files
          master_item:
            key: 'pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: archive
        - uuid: 218b03c8bfb84b07ae0ec9ba0932fff3
          name: 'Get archive'
          type: ZABBIX_ACTIVE
          key: 'pgsql.archive["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: 'Collect archive status metrics.'
          tags:
            - tag: component
              value: raw
        - uuid: bc14c8544eed47ce9510a803be5708d7
          name: 'Count of autovacuum workers'
          type: ZABBIX_ACTIVE
          key: 'pgsql.autovacuum.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          value_type: FLOAT
          description: 'Number of autovacuum workers.'
          tags:
            - tag: component
              value: system
        - uuid: eadfb41d59a84315a8b3540005fc9138
          name: 'Bgwriter: Buffers allocated per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_alloc.rate
          value_type: FLOAT
          description: 'Number of buffers allocated per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_alloc
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 6c1df723638b435a813e144b730bab0a
          name: 'Bgwriter: Buffers written directly by a backend per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_backend.rate
          value_type: FLOAT
          description: 'Number of buffers written directly by a backend per second. Available in PostgreSQL versions prior to 17.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_backend
              error_handler: DISCARD_VALUE
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 2e0f72740975437d94807cc1ea3a52cd
          name: 'Bgwriter: Times a backend executed its own fsync per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_backend_fsync.rate
          value_type: FLOAT
          description: 'Number of times a backend had to execute its own fsync call per second (normally the background writer handles those even when the backend does its own write). Available in PostgreSQL versions prior to 17.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_backend_fsync
              error_handler: DISCARD_VALUE
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 84bffdbacf8449e48a58a15f3363d3b2
          name: 'Checkpoint: Buffers written during checkpoints per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_checkpoint.rate
          value_type: FLOAT
          description: 'Number of buffers written during checkpoints per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_checkpoint
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 98cace696df64de8a5f5106a8c2c52ba
          name: 'Checkpoint: Buffers written by the background writer per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_clean.rate
          value_type: FLOAT
          description: 'Number of buffers written by the background writer per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_clean
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 35b2f1af4e1f45d9b729eb09757ce6e4
          name: 'Checkpoint: Requested per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoints_req.rate
          value_type: FLOAT
          description: 'Number of requested checkpoints that have been performed per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoints_req
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: a3d03d5bba4d4bb0a1ed52f684143ca5
          name: 'Checkpoint: Scheduled per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoints_timed.rate
          value_type: FLOAT
          description: 'Number of scheduled checkpoints that have been performed per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoints_timed
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 7ff2d5d51057451fb2089e92444feb84
          name: 'Checkpoint: Checkpoint sync time per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoint_sync_time.rate
          value_type: FLOAT
          units: s
          description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoint_sync_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 7217bdae3d72478aae2c2cc1c151f203
          name: 'Checkpoint: Checkpoint write time per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoint_write_time.rate
          value_type: FLOAT
          units: s
          description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoint_write_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: d0cb711ca251430ab0c1beb5f2617c6d
          name: 'Bgwriter: Number of bgwriter cleaning scan stopped per second'
          type: DEPENDENT
          key: pgsql.bgwriter.maxwritten_clean.rate
          value_type: FLOAT
          description: 'Number of times the background writer stopped a cleaning scan because it had written too many buffers per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.maxwritten_clean
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 8d0dd45f06974d6b8be9cc11404ac1c3
          name: 'Get bgwriter'
          type: ZABBIX_ACTIVE
          key: 'pgsql.bgwriter["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_bgwriter:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: 7b701ad8f20a44958956a6cbfd4e5da2
          name: 'Cache hit ratio, %'
          type: CALCULATED
          key: pgsql.cache.hit
          value_type: FLOAT
          units: '%'
          params: 'last(//pgsql.dbstat.sum.blks_hit.rate) * 100 / (last(//pgsql.dbstat.sum.blks_hit.rate) + last(//pgsql.dbstat.sum.blks_read.rate))'
          description: 'Cache hit ratio.'
          tags:
            - tag: component
              value: cache
        - uuid: 20eca5056709454189394db755132cb5
          name: 'Connections sum: Active'
          type: DEPENDENT
          key: pgsql.connections.sum.active
          description: 'Total number of connections executing a query.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.active
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 8ff6487a87d049ae95a4465b5c3cf438
          name: 'Connections sum: Disabled'
          type: DEPENDENT
          key: pgsql.connections.sum.disabled
          description: 'Total number of disabled connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.disabled
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: dde39d43bd8e45e29e6ca2ab28d34499
          name: 'Connections sum: Fastpath function call'
          type: DEPENDENT
          key: pgsql.connections.sum.fastpath_function_call
          description: 'Total number of connections executing a fast-path function.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.fastpath_function_call
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 4717491488f642f5ad40d93da59793f5
          name: 'Connections sum: Idle'
          type: DEPENDENT
          key: pgsql.connections.sum.idle
          description: 'Total number of connections waiting for a new client command.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: cda45db6de6d4deeb988235f0c7d9376
          name: 'Connections sum: Idle in transaction'
          type: DEPENDENT
          key: pgsql.connections.sum.idle_in_transaction
          description: 'Total number of connections in a transaction state but not executing a query.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle_in_transaction
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 503826ace4f848ada43abc60ff7c1ee2
          name: 'Connections sum: Idle in transaction (aborted)'
          type: DEPENDENT
          key: pgsql.connections.sum.idle_in_transaction_aborted
          description: 'Total number of connections in a transaction state but not executing a query, and where one of the statements in the transaction caused an error.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle_in_transaction_aborted
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 604c4b1fd04249be896c7588bf2c6b23
          name: 'Connections sum: Prepared'
          type: DEPENDENT
          key: pgsql.connections.sum.prepared
          description: |
            Total number of prepared transactions:
            https://www.postgresql.org/docs/current/sql-prepare-transaction.html
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.prepared
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: d7faa8068a8f4877b77fb5120bbe6d8d
          name: 'Connections sum: Total'
          type: DEPENDENT
          key: pgsql.connections.sum.total
          description: 'Total number of connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 85b9cf0643fc4cf289f8b0ac364e8879
          name: 'Connections sum: Total, %'
          type: DEPENDENT
          key: pgsql.connections.sum.total_pct
          units: '%'
          description: 'Total number of connections, in percentage.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total_pct
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: f07fbe410afa48e6a08da06f4af504c5
              expression: 'min(/PostgreSQL by Zabbix agent 2 active/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN}'
              name: 'PostgreSQL: Total number of connections is too high'
              event_name: 'PostgreSQL: Total number of connections is too high (over {$PG.CONN_TOTAL_PCT.MAX.WARN} in 5m)'
              priority: AVERAGE
              description: 'Total number of current connections exceeds the limit of {$PG.CONN_TOTAL_PCT.MAX.WARN}% out of the maximum number of concurrent connections to the database server (the "max_connections" setting).'
              tags:
                - tag: scope
                  value: performance
        - uuid: 2a05cc636fc0432386a5c6c00ac2777b
          name: 'Connections sum: Waiting'
          type: DEPENDENT
          key: pgsql.connections.sum.waiting
          description: |
            Total number of waiting connections:
            https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.waiting
          master_item:
            key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 52d9d2342b9c40a2b279dcbe4bcff023
          name: 'Get connections sum'
          type: ZABBIX_ACTIVE
          key: 'pgsql.connections["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_activity:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: defcba230619484db1a7d6faace8b33d
          name: 'Custom queries'
          type: ZABBIX_ACTIVE
          key: 'pgsql.custom.query["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}",""]'
          history: 1h
          value_type: TEXT
          status: DISABLED
          description: 'Execute custom queries from file *.sql (check for option Plugins.Postgres.CustomQueriesPath at agent configuration).'
          tags:
            - tag: component
              value: application
        - uuid: dbdeb7a7fc9f4187b29fb0dae2f2af62
          name: 'Dbstat: Hit blocks read per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blks_hit.rate
          value_type: FLOAT
          description: 'Number of times per second disk blocks were found already in the buffer cache'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blks_hit
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: cache
        - uuid: 136db4803969403ebf2fdb97e1e3b1ec
          name: 'Dbstat: Disk blocks read per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blks_read.rate
          value_type: FLOAT
          description: 'Number of disk blocks read per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blks_read
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: storage
        - uuid: badd110db2c64debb5619819299d7d47
          name: 'Dbstat: Blocks read time'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blk_read_time
          value_type: FLOAT
          units: s
          description: 'Time spent reading data file blocks by backends.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blk_read_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: storage
        - uuid: 310219edd25c45b19ca7ee9e3621331a
          name: 'Dbstat: Blocks write time'
          type: DEPENDENT
          key: pgsql.dbstat.sum.blk_write_time
          value_type: FLOAT
          units: s
          description: 'Time spent writing data file blocks by backends.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.blk_write_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: storage
        - uuid: f59fe2b665c94405b82bbc523aff1988
          name: 'Dbstat: Checksum failures per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.checksum_failures.rate
          value_type: FLOAT
          description: 'Number of data page checksum failures per second detected (or on a shared object), or NULL if data checksums are not enabled. This metric is available since PostgreSQL 12.'
          valuemap:
            name: 'PostgreSQL checksum failure status'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checksum_failures
            - type: MATCHES_REGEX
              parameters:
                - '^\d*$'
              error_handler: CUSTOM_VALUE
              error_handler_params: '-2'
            - type: CHANGE_PER_SECOND
              error_handler: CUSTOM_VALUE
              error_handler_params: '-1'
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: 15357041a8774ae19a6cfa64154a4395
              expression: 'last(/PostgreSQL by Zabbix agent 2 active/pgsql.dbstat.sum.checksum_failures.rate)>0'
              name: 'PostgreSQL: Dbstat: Checksum failures detected'
              priority: AVERAGE
              description: |
                Data page checksum failures were detected on that DB instance:
                https://www.postgresql.org/docs/current/checksums.html
              tags:
                - tag: scope
                  value: availability
        - uuid: e53fc92d8d4b4f8690901f4eb736ca8a
          name: 'Dbstat: Conflicts per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.conflicts.rate
          value_type: FLOAT
          description: 'Number of queries canceled per second due to conflicts with recovery (conflicts occur only on standby servers; see pg_stat_database_conflicts for details).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.conflicts
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 5ffee9612e844f15bfb1869f9f139171
          name: 'Dbstat: Deadlocks per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.deadlocks.rate
          value_type: FLOAT
          description: 'Number of deadlocks detected per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.deadlocks
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: deadlocks
        - uuid: b7fecc03343045478e54f21a4406e793
          name: 'Dbstat: Backends connected'
          type: DEPENDENT
          key: pgsql.dbstat.sum.numbackends
          description: 'Number of connected backends.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.numbackends
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: backends
        - uuid: 1e95365a6e9c461aa7f09c407ecc7844
          name: 'Dbstat: Number temp bytes per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.temp_bytes.rate
          value_type: FLOAT
          units: b
          description: 'Total amount of data written per second to temporary files by queries.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.temp_bytes
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: storage
        - uuid: 848bf15ec1c840959c83eba95645a810
          name: 'Dbstat: Number temp files per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.temp_files.rate
          value_type: FLOAT
          description: 'Number of temporary files created by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.temp_files
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: storage
        - uuid: db78e1e34e154bfca1e3fbc1fd1f0f20
          name: 'Dbstat: Rows deleted per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_deleted.rate
          value_type: FLOAT
          description: 'Number of rows deleted by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_deleted
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 3a1d49dd854d442aa0cafbc8025a942c
          name: 'Dbstat: Rows fetched per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_fetched.rate
          value_type: FLOAT
          description: 'Number of rows fetched by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_fetched
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: fc3e55d1a7d147049715b064bdf234b0
          name: 'Dbstat: Rows inserted per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_inserted.rate
          value_type: FLOAT
          description: 'Number of rows inserted by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_inserted
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: a92bc6f9bbbb4bf5b8289568b89642c8
          name: 'Dbstat: Rows returned per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_returned.rate
          value_type: FLOAT
          description: 'Number of rows returned by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_returned
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: 9f8498a20db04822b0d03df4d8cb184e
          name: 'Dbstat: Rows updated per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.tup_updated.rate
          value_type: FLOAT
          description: 'Number of rows updated by queries per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tup_updated
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: queries
        - uuid: fed4fd91cbf846929795b960266301b7
          name: 'Dbstat: Committed transactions per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.xact_commit.rate
          value_type: FLOAT
          description: 'Number of transactions that have been committed per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.xact_commit
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: e3337867025d4cd7bc4d26d663a4fc61
          name: 'Dbstat: Roll backed transactions per second'
          type: DEPENDENT
          key: pgsql.dbstat.sum.xact_rollback.rate
          value_type: FLOAT
          description: 'Number of transactions that have been rolled back per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.xact_rollback
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: 8d84c4ec8d05427f9da4b9a1904a0af4
          name: 'Get dbstat sum'
          type: ZABBIX_ACTIVE
          key: 'pgsql.dbstat.sum["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_database as sums for all databases:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: e36f2b3e33e2435d9b95472a7844a1a4
          name: 'Get dbstat'
          type: ZABBIX_ACTIVE
          key: 'pgsql.dbstat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_database per database:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: df19db910015411996e25ea5b48f0742
          name: 'Get locks'
          type: ZABBIX_ACTIVE
          key: 'pgsql.locks["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_locks per database:
            https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES
          tags:
            - tag: component
              value: raw
        - uuid: 1a32b0308496460b83ad2698edb21420
          name: 'Age of oldest xid'
          type: ZABBIX_ACTIVE
          key: 'pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          value_type: FLOAT
          description: 'Age of oldest xid.'
          tags:
            - tag: component
              value: transactions
          triggers:
            - uuid: 233757fda5784d9fb264bd0d4a7765ac
              expression: 'last(/PostgreSQL by Zabbix agent 2 active/pgsql.oldest.xid["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) > 18000000'
              name: 'PostgreSQL: Oldest xid is too big'
              priority: AVERAGE
              tags:
                - tag: scope
                  value: availability
        - uuid: 52edd592df6f49df9bf46b5e93689a1a
          name: Ping
          type: ZABBIX_ACTIVE
          key: 'pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Used to test a connection to see if it is alive. It is set to 0 if the query is unsuccessful.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: ab52bca5bae940cdad5b7eead56f2ff9
              expression: 'last(/PostgreSQL by Zabbix agent 2 active/pgsql.ping["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"])=0'
              name: 'PostgreSQL: Service is down'
              priority: HIGH
              description: 'Last test of a connection was unsuccessful.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 060c0efaf60944538bf5fb6ca2828dc6
          name: 'Get queries'
          type: ZABBIX_ACTIVE
          key: 'pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"]'
          history: '0'
          value_type: TEXT
          description: 'Collect all metrics by query execution time.'
          tags:
            - tag: component
              value: raw
        - uuid: f15d0758764c4bd6b607335d9d57b76b
          name: 'Replication: Standby count'
          type: ZABBIX_ACTIVE
          key: 'pgsql.replication.count["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Number of standby servers.'
          tags:
            - tag: component
              value: replication
        - uuid: a3297ef8198145848d4e3b16b7b8eb8b
          name: 'Replication: Lag in bytes'
          type: ZABBIX_ACTIVE
          key: 'pgsql.replication.lag.b["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          units: B
          description: 'Replication lag with master, in bytes.'
          tags:
            - tag: component
              value: replication
        - uuid: 142e93b332e24ecfbd50465bb4af91e7
          name: 'Replication: Lag in seconds'
          type: ZABBIX_ACTIVE
          key: 'pgsql.replication.lag.sec["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          units: s
          description: 'Replication lag with master, in seconds.'
          tags:
            - tag: component
              value: replication
        - uuid: aa03fb9cabd8459ea5f5efb90c9e1051
          name: 'Get replication'
          type: ZABBIX_ACTIVE
          key: 'pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: 'Collect metrics from the pg_stat_replication, which contains information about the WAL sender process, showing statistics about replication to that sender''s connected standby server.'
          tags:
            - tag: component
              value: raw
        - uuid: 226bcc226ffc487ba90d998a03692404
          name: 'Replication: Recovery role'
          type: ZABBIX_ACTIVE
          key: 'pgsql.replication.recovery_role["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode.'
          valuemap:
            name: 'PostgreSQL recovery role'
          tags:
            - tag: component
              value: replication
        - uuid: ef2ac5eaf73c40e09af41bba03b4fac8
          name: 'Replication: Status'
          type: ZABBIX_ACTIVE
          key: 'pgsql.replication.status["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode.'
          valuemap:
            name: 'PostgreSQL replication status'
          tags:
            - tag: component
              value: replication
        - uuid: 46b53fcf97a74619a03c2490fe9b71ea
          name: Uptime
          type: ZABBIX_ACTIVE
          key: 'pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          value_type: FLOAT
          units: uptime
          description: 'Time since the server started.'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: ec3d8fb289234e84b300b83ce169137f
              expression: 'last(/PostgreSQL by Zabbix agent 2 active/pgsql.uptime["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m'
              name: 'PostgreSQL: Service has been restarted'
              event_name: 'PostgreSQL: Service has been restarted (uptime < 10m)'
              priority: AVERAGE
              description: 'PostgreSQL uptime is less than 10 minutes.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 7a96feee8118450e83e994be87bc5eea
          name: Version
          type: ZABBIX_ACTIVE
          key: 'pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 15m
          value_type: CHAR
          description: 'PostgreSQL version.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 0d8c3bf10b4e42f796f72136768ce6ab
              expression: 'last(/PostgreSQL by Zabbix agent 2 active/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent 2 active/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent 2 active/pgsql.version["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0'
              name: 'PostgreSQL: Version has changed'
              event_name: 'PostgreSQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              tags:
                - tag: scope
                  value: notice
        - uuid: 5fc77f9d1d1d46ed84d71dedaf30de75
          name: 'WAL: Segments count'
          type: DEPENDENT
          key: pgsql.wal.count
          description: 'Number of WAL segments.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.count
          master_item:
            key: 'pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: wal
        - uuid: 78f6cd549ecc417880df1851d8427722
          name: 'WAL: Bytes received'
          type: DEPENDENT
          key: pgsql.wal.receive
          units: B
          description: 'WAL receive, in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.receive
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: wal
        - uuid: cb2a0f990a39411e9d3c7d95cc7504ee
          name: 'Get WAL'
          type: ZABBIX_ACTIVE
          key: 'pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 5m
          history: '0'
          value_type: TEXT
          description: 'Collect write-ahead log (WAL) metrics.'
          tags:
            - tag: component
              value: raw
        - uuid: 492f311473f645f19b79f46d07c9950a
          name: 'WAL: Bytes written'
          type: DEPENDENT
          key: pgsql.wal.write
          units: B
          description: 'WAL write, in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.write
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.wal.stat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: wal
      discovery_rules:
        - uuid: c5a95125be304bbeba407ce926ad7816
          name: 'Database discovery'
          type: ZABBIX_ACTIVE
          key: 'pgsql.db.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 1h
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DBNAME}'
                value: '{$PG.LLD.FILTER.DBNAME}'
          description: |
            Discovers databases (DB) in the database management system (DBMS), except:
            - templates;
            - DBs that do not allow connections.
          item_prototypes:
            - uuid: 7df48c3384b14356903c38b3b0e1c435
              name: 'DB [{#DBNAME}]: Database age'
              type: ZABBIX_ACTIVE
              key: 'pgsql.db.age["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              delay: 10m
              description: 'Database age.'
              tags:
                - tag: component
                  value: application
                - tag: database
                  value: '{#DBNAME}'
            - uuid: cd5516d8ea994a9e86aff2081d611176
              name: 'DB [{#DBNAME}]: Bloating tables'
              type: ZABBIX_ACTIVE
              key: 'pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              description: 'Number of bloating tables.'
              tags:
                - tag: component
                  value: tables
                - tag: database
                  value: '{#DBNAME}'
            - uuid: f2d58306483d4bb4a215e245f133b4ad
              name: 'DB [{#DBNAME}]: Database size'
              type: ZABBIX_ACTIVE
              key: 'pgsql.db.size["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              delay: 5m
              units: B
              description: 'Database size.'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: ce43087066804e828d8a64eb0cc13ac6
              name: 'DB [{#DBNAME}]: Blocks hit per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blks_hit
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: cache
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 01d227b759d7404481e12e0daa90b3bb
              name: 'DB [{#DBNAME}]: Disk blocks read per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of disk blocks read per second in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blks_read
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 1592dc3a802944cf8946bfee38652d44
              name: 'DB [{#DBNAME}]: Disk blocks read time per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blk_read_time.rate["{#DBNAME}"]'
              value_type: FLOAT
              units: s
              description: 'Time spent reading data file blocks by backends per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blk_read_time
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 491b9e40b3a243d6b22fb24124d98293
              name: 'DB [{#DBNAME}]: Disk blocks write time'
              type: DEPENDENT
              key: 'pgsql.dbstat.blk_write_time.rate["{#DBNAME}"]'
              value_type: FLOAT
              units: s
              description: 'Time spent writing data file blocks by backends per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blk_write_time
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 9540fc8baf2c4b0b81e4d8eafe1f57cf
              name: 'DB [{#DBNAME}]: Checksum failures'
              type: DEPENDENT
              key: 'pgsql.dbstat.checksum_failures.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of data page checksum failures detected in this database.'
              valuemap:
                name: 'PostgreSQL checksum failure status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.checksum_failures
                - type: MATCHES_REGEX
                  parameters:
                    - '^\d*$'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '-2'
                - type: CHANGE_PER_SECOND
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '-1'
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: system
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: b0a2935d0a984233a530cf47d8fc606b
                  expression: 'last(/PostgreSQL by Zabbix agent 2 active/pgsql.dbstat.checksum_failures.rate["{#DBNAME}"])>0'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Checksum failures detected'
                  priority: AVERAGE
                  description: |
                    Data page checksum failures were detected on that database:
                    https://www.postgresql.org/docs/current/checksums.html
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 3e48cd0cf7214f77b8b6d9e76c1def00
              name: 'DB [{#DBNAME}]: Detected conflicts per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of queries canceled due to conflicts with recovery in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.conflicts
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: d156ed02bcad4123a827a3d7900bed1e
                  expression: 'min(/PostgreSQL by Zabbix agent 2 active/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts (over {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: AVERAGE
                  description: |
                    The primary and standby servers are in many ways loosely connected. Actions on the primary will have an effect on the standby. As a result, there is potential for negative interactions or conflicts between them.
                    https://www.postgresql.org/docs/current/hot-standby.html#HOT-STANDBY-CONFLICT
                  tags:
                    - tag: scope
                      value: performance
            - uuid: 43aab996a12a49c582d46f96f999ab89
              name: 'DB [{#DBNAME}]: Detected deadlocks per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of detected deadlocks in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.deadlocks
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: deadlocks
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: d188109b522b4ff896ed08fb04cf5f9d
                  expression: 'min(/PostgreSQL by Zabbix agent 2 active/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Deadlock occurred'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Deadlock occurred (over {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: HIGH
                  description: 'Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m.'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 02c15c6f80e644269e14e5047f07efb1
              name: 'DB [{#DBNAME}]: Get dbstat'
              type: DEPENDENT
              key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get dbstat metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.dbstat["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 2e8648e519524533b430bdf863561ba4
              name: 'DB [{#DBNAME}]: Backends connected'
              type: DEPENDENT
              key: 'pgsql.dbstat.numbackends["{#DBNAME}"]'
              description: 'Number of backends currently connected to this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.numbackends
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: backends
                - tag: database
                  value: '{#DBNAME}'
            - uuid: d2a01165e7c24969b26cdebe42f53c39
              name: 'DB [{#DBNAME}]: Temp_bytes written per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
              units: B
              description: 'Total amount of data written to temporary files by queries in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.temp_bytes
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 74dc57aaeba74b599cda10817961d5da
              name: 'DB [{#DBNAME}]: Temp_files created per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
              description: 'Total number of temporary files created by queries in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.temp_files
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: ec42f02be51b49789d1ad1fc3d636be4
              name: 'DB [{#DBNAME}]: Tuples deleted per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows deleted by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_deleted
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: ffa697ab71734806aac1102c7d133521
              name: 'DB [{#DBNAME}]: Tuples fetched per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows fetched by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_fetched
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 8fe771d00b5648758c0d568cb1d7b207
              name: 'DB [{#DBNAME}]: Tuples inserted per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows inserted by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_inserted
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: aeb15898d242406393108df7bfd52881
              name: 'DB [{#DBNAME}]: Tuples returned per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of rows returned by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_returned
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 22dee9fb2db8478caf1fd83f415414ef
              name: 'DB [{#DBNAME}]: Tuples updated per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows updated by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_updated
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 2bfdd988bca74df5a31dbf3727aa10a0
              name: 'DB [{#DBNAME}]: Commits per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of transactions in this database that have been committed per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.xact_commit
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: b7edf603e83a48bca580e932fc87c5cf
              name: 'DB [{#DBNAME}]: Rollbacks per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of transactions in this database that have been rolled back.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.xact_rollback
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: af381c8bd21c4189b6b8230325c97358
              name: 'DB [{#DBNAME}]: Num of accessexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.accessexclusive["{#DBNAME}"]'
              description: 'Number of accessexclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.accessexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: fe133b91b9a3474ab5ed12055c277969
              name: 'DB [{#DBNAME}]: Num of accessshare locks'
              type: DEPENDENT
              key: 'pgsql.locks.accessshare["{#DBNAME}"]'
              description: 'Number of accessshare locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.accessshare
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 3a28968abd5945cebb1157ae74e2de7d
              name: 'DB [{#DBNAME}]: Num of exclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.exclusive["{#DBNAME}"]'
              description: 'Number of exclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.exclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: ce03b994ad894100a11816b043d84c23
              name: 'DB [{#DBNAME}]: Get locks'
              type: DEPENDENT
              key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get locks metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.locks["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 8bb0fe1e02ef4ad19f4367dbc67e9bc0
              name: 'DB [{#DBNAME}]: Num of rowexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.rowexclusive["{#DBNAME}"]'
              description: 'Number of rowexclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rowexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 9821b111e1e741a592c962c503129eae
              name: 'DB [{#DBNAME}]: Num of rowshare locks'
              type: DEPENDENT
              key: 'pgsql.locks.rowshare["{#DBNAME}"]'
              description: 'Number of rowshare locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rowshare
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 94b2491b18d74345b5bd33a523049cbf
              name: 'DB [{#DBNAME}]: Num of sharerowexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.sharerowexclusive["{#DBNAME}"]'
              description: 'Number of total sharerowexclusive for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.sharerowexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 888f4f0f47b54d708d87b22efa25f0e5
              name: 'DB [{#DBNAME}]: Num of shareupdateexclusive locks'
              type: DEPENDENT
              key: 'pgsql.locks.shareupdateexclusive["{#DBNAME}"]'
              description: 'Number of shareupdateexclusive locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.shareupdateexclusive
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 70abd9b269f94310875c1777c089741b
              name: 'DB [{#DBNAME}]: Num of share locks'
              type: DEPENDENT
              key: 'pgsql.locks.share["{#DBNAME}"]'
              description: 'Number of share locks for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.share
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 19d118b8a99845ef8d2eaaa5ec38f50d
              name: 'DB [{#DBNAME}]: Num of locks total'
              type: DEPENDENT
              key: 'pgsql.locks.total["{#DBNAME}"]'
              description: 'Total number of locks in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.total
              master_item:
                key: 'pgsql.locks.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 15cf79b8fafa442a80a10368f5b5962d
              name: 'DB [{#DBNAME}]: Get queries'
              type: DEPENDENT
              key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get queries metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.queries["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: f8c0e60c70d14103b39b1a6218093c0a
              name: 'DB [{#DBNAME}]: Queries slow maintenance count'
              type: DEPENDENT
              key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
              description: 'Slow maintenance query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 8d16b715b12648f5b5dca0f80857e46e
              name: 'DB [{#DBNAME}]: Queries max maintenance time'
              type: DEPENDENT
              key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
              units: s
              description: 'Max maintenance query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: af2c1c09b2a04911b2e6e892d1051e94
              name: 'DB [{#DBNAME}]: Queries sum maintenance time'
              type: DEPENDENT
              key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum maintenance query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: bd070ec5cbcf42a7a2dfa56dd3eca7a3
              name: 'DB [{#DBNAME}]: Queries slow query count'
              type: DEPENDENT
              key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
              description: 'Slow query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: be059c5eb7b6442b8312ef58b2bc55cc
                  expression: 'min(/PostgreSQL by Zabbix agent 2 active/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Too many slow queries'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Too many slow queries (over {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: WARNING
                  description: 'The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}.'
                  tags:
                    - tag: scope
                      value: performance
            - uuid: 827abbb549b640f28a7984ba157de73e
              name: 'DB [{#DBNAME}]: Queries max query time'
              type: DEPENDENT
              key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
              units: s
              description: 'Max query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 93a773701de54ce3a3af3d651167c0a9
              name: 'DB [{#DBNAME}]: Queries sum query time'
              type: DEPENDENT
              key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: ee6fb28b33424ffab8e336280cfe5d7e
              name: 'DB [{#DBNAME}]: Queries slow transaction count'
              type: DEPENDENT
              key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
              description: 'Slow transaction query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 73c67fc53f944fb6a15c0e0776ba4cf3
              name: 'DB [{#DBNAME}]: Queries max transaction time'
              type: DEPENDENT
              key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
              units: s
              description: 'Max transaction query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 62771b2b28f94f93b54ea5e31f336938
              name: 'DB [{#DBNAME}]: Queries sum transaction time'
              type: DEPENDENT
              key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum transaction query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
          graph_prototypes:
            - uuid: 2c0fea3adf254d41b123fb69202c51fe
              name: 'DB [{#DBNAME}]: Locks'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.locks.total["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.locks.accessexclusive["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.locks.accessshare["{#DBNAME}"]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.locks.exclusive["{#DBNAME}"]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.locks.rowexclusive["{#DBNAME}"]'
                - sortorder: '5'
                  color: 6C59DC
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.locks.rowshare["{#DBNAME}"]'
                - sortorder: '6'
                  color: C7A72D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.locks.sharerowexclusive["{#DBNAME}"]'
                - sortorder: '7'
                  color: BA2A5D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.locks.shareupdateexclusive["{#DBNAME}"]'
                - sortorder: '8'
                  color: F230E0
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.locks.share["{#DBNAME}"]'
            - uuid: 96144801ca8a4c02ac88c49f0fb4eb7c
              name: 'DB [{#DBNAME}]: Number of bloating tables'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.db.bloating_tables["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
            - uuid: 55268d2bc7224902836b8ec683b82865
              name: 'DB [{#DBNAME}]: pg_stat_database metrics'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
                - sortorder: '5'
                  color: 6C59DC
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
                - sortorder: '6'
                  color: C7A72D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
                - sortorder: '7'
                  color: BA2A5D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
                - sortorder: '8'
                  color: F230E0
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
                - sortorder: '9'
                  color: 5CCD18
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
                - sortorder: '10'
                  color: BB2A02
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
                - sortorder: '11'
                  color: AC41A5
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
                - sortorder: '12'
                  color: 89ABF8
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
            - uuid: 7d0246026bae4e6680f19626fba2bc02
              name: 'DB [{#DBNAME}]: Queries'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
                - sortorder: '3'
                  drawtype: GRADIENT_LINE
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
                - sortorder: '4'
                  drawtype: GRADIENT_LINE
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
                - sortorder: '5'
                  drawtype: GRADIENT_LINE
                  color: 6C59DC
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
            - uuid: 9a4b7b68ae0f4291a970e3e1838368c6
              name: 'DB [{#DBNAME}]: Size'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.db.size["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
            - uuid: 31c3e16c49ba486db9f6f92714d927b6
              name: 'DB [{#DBNAME}]: Slow queries'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
        - uuid: 92ba6c1b038a454d8d8d40399d0967d8
          name: 'Replication discovery'
          type: ZABBIX_ACTIVE
          key: 'pgsql.replication.process.discovery["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 15m
          filter:
            evaltype: AND
            conditions:
              - macro: '{#APPLICATION_NAME}'
                value: '{$PG.LLD.FILTER.APPLICATION}'
          description: 'Discovers replication lag metrics.'
          item_prototypes:
            - uuid: 7d994bb6b0de4f76810e4beaf9c6318c
              name: 'Application [{#APPLICATION_NAME}]: Get replication'
              type: DEPENDENT
              key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Collect metrics from the "pg_stat_replication" about the application "{#APPLICATION_NAME}" that is connected to this WAL sender, which contains information about the WAL sender process, showing statistics about replication to that sender''s connected standby server.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#APPLICATION_NAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.replication.process["{$PG.CONNSTRING.AGENT2}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: raw
            - uuid: 33541a2ce9894c71aef710d1e227dab2
              name: 'Application [{#APPLICATION_NAME}]: Replication flush lag'
              type: DEPENDENT
              key: 'pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"]'
              value_type: FLOAT
              units: s
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.flush_lag
              master_item:
                key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: replication
            - uuid: 4ef7353e3b904f33ac2b592d5cbfba62
              name: 'Application [{#APPLICATION_NAME}]: Replication replay lag'
              type: DEPENDENT
              key: 'pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"]'
              value_type: FLOAT
              units: s
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.replay_lag
              master_item:
                key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: replication
            - uuid: 3beb600f296c4263b92434a46bd946cd
              name: 'Application [{#APPLICATION_NAME}]: Replication write lag'
              type: DEPENDENT
              key: 'pgsql.replication.process.write_lag["{#APPLICATION_NAME}"]'
              value_type: FLOAT
              units: s
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.write_lag
              master_item:
                key: 'pgsql.replication.get_metrics["{#APPLICATION_NAME}"]'
              tags:
                - tag: application
                  value: '{#APPLICATION_NAME}'
                - tag: component
                  value: replication
          graph_prototypes:
            - uuid: 3942169cc1eb4715a5f2ca0ee58c33df
              name: 'Application [{#APPLICATION_NAME}]: Replication lag'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.replication.process.flush_lag["{#APPLICATION_NAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.replication.process.replay_lag["{#APPLICATION_NAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent 2 active'
                    key: 'pgsql.replication.process.write_lag["{#APPLICATION_NAME}"]'
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: postgresql
      macros:
        - macro: '{$PG.CONFLICTS.MAX.WARN}'
          value: '0'
          description: 'Maximum number of recovery conflicts for trigger expression.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Maximum number of recovery conflicts'
            description: 'Maximum number of recovery conflicts for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.CONNSTRING.AGENT2}'
          value: 'tcp://localhost:5432'
          description: 'URI or named session of the PostgreSQL instance.'
          config:
            type: TEXT
            priority: '1'
            label: 'PostgreSQL connection string'
            description: 'URI or named session of the PostgreSQL instance.'
            required: 'YES'
        - macro: '{$PG.CONN_TOTAL_PCT.MAX.WARN}'
          value: '90'
          description: 'Maximum percentage of current connections for trigger expression.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Maximum percentage of current connections'
            description: 'Maximum percentage of current connections for trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.DATABASE}'
          value: postgres
          description: 'Default PostgreSQL database for the connection.'
          config:
            type: TEXT
            priority: '4'
            label: 'Default PostgreSQL database for the connection'
            required: 'YES'
        - macro: '{$PG.DEADLOCKS.MAX.WARN}'
          value: '0'
          description: 'Maximum number of detected deadlocks for trigger expression.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Maximum number of detected deadlocks'
            description: 'Maximum number of detected deadlocks for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.LLD.FILTER.APPLICATION}'
          value: .+
          description: 'Filter of discoverable applications.'
          config:
            type: TEXT
            priority: '6'
            section_name: Filters
            label: 'Applications LLD filter'
            description: 'Filter of discoverable applications.'
        - macro: '{$PG.LLD.FILTER.DBNAME}'
          value: .+
          description: 'Filter of discoverable databases.'
          config:
            type: TEXT
            priority: '5'
            section_name: Filters
            label: 'Database name LLD filter'
            description: 'Filter of discoverable databases.'
        - macro: '{$PG.PASSWORD}'
          type: SECRET_TEXT
          description: 'PostgreSQL user password.'
          config:
            type: TEXT
            priority: '3'
            label: 'PostgreSQL user password'
            required: 'YES'
        - macro: '{$PG.QUERY_ETIME.MAX.WARN}'
          value: '30'
          description: 'Execution time limit for count of slow queries.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'Slow queries execution time threshold'
            description: 'Execution time threshold for queries to be considered slow. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.SLOW_QUERIES.MAX.WARN}'
          value: '5'
          description: 'Slow queries count threshold for a trigger.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'Slow queries count threshold'
            description: 'Slow queries count threshold for a trigger. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.USER}'
          value: zbx_monitor
          description: 'PostgreSQL username.'
          config:
            type: TEXT
            priority: '2'
            label: 'PostgreSQL username'
            required: 'YES'
      dashboards:
        - uuid: ee3e7ee2f7de495997f4749a23f00f48
          name: 'PostgreSQL databases'
          pages:
            - widgets:
                - type: graphprototype
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2 active'
                        name: 'DB [{#DBNAME}]: pg_stat_database metrics'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graphprototype
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2 active'
                        name: 'DB [{#DBNAME}]: Size'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graphprototype
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2 active'
                        name: 'DB [{#DBNAME}]: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graphprototype
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2 active'
                        name: 'DB [{#DBNAME}]: Locks'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graphprototype
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2 active'
                        name: 'DB [{#DBNAME}]: Number of bloating tables'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graphprototype
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent 2 active'
                        name: 'DB [{#DBNAME}]: Slow queries'
                    - type: STRING
                      name: reference
                      value: AAAAF
      valuemaps:
        - uuid: 9b9961c136c4426bb6d11c749cbb4cfa
          name: 'PostgreSQL checksum failure status'
          mappings:
            - value: '-2'
              newvalue: 'null'
        - uuid: bf1b2c09ce844d9c8b2735901fe77a03
          name: 'PostgreSQL recovery role'
          mappings:
            - value: '0'
              newvalue: Master
            - value: '1'
              newvalue: Standby
        - uuid: ee126cb6f7e14a93ae1e21106ee8732f
          name: 'PostgreSQL replication status'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
            - value: '2'
              newvalue: Master
        - uuid: e11dca50f6e4481fa1fda75aeb71cf8c
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
    - uuid: 7005acc9123e4bc290805a3a16dab9cf
      template: 'PostgreSQL by Zabbix agent active'
      name: 'PostgreSQL by Zabbix agent active'
      description: |
        This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent and uses user parameters to run SQL queries with the `psql` command-line tool.
        
        Note:
        - The template requires `pg_isready` and `psql` utilities to be installed on the same host with Zabbix agent.
        - The template requires files with SQL queries and user parameters that can be found in the Zabbix official repository:
        https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql?at=refs%2Fheads%2Frelease%2F6.0
        
        Setup:
        
        1. Deploy Zabbix agent and create the PostgreSQL user for monitoring (`<password>` at your discretion) with proper access rights to your PostgreSQL instance.
        
        For PostgreSQL version 10 and above:
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
        GRANT pg_monitor TO zbx_monitor;
        
        For PostgreSQL version 9.6 and below:
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>';
        GRANT SELECT ON pg_stat_database TO zbx_monitor;
        ALTER USER zbx_monitor WITH SUPERUSER;
        
        2. Copy the `postgresql/` directory to the `zabbix` user home directory - `/var/lib/zabbix/`. The `postgresql/` directory contains the files with SQL queries needed to obtain metrics from PostgreSQL instance.
        
        If the home directory of the `zabbix` user doesn't exist, create it first:
        mkdir -m u=rwx,g=rwx,o= -p /var/lib/zabbix
        chown zabbix:zabbix /var/lib/zabbix
        
        3. Copy the `template_db_postgresql.conf` file, containing user parameters, to the Zabbix agent configuration directory `/etc/zabbix/zabbix_agentd.d/` and restart Zabbix agent service.
        
        If you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, you can modify the connection string in user parameters. For example, to enable required encryption in transport mode without identity checks you could append `?sslmode=required` to the end of the connection string for all keys that use `psql`:
        UserParameter=pgsql.bgwriter[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5"?sslmode=required -f "/var/lib/zabbix/postgresql/pgsql.bgwriter.sql"
        
        Consult the PostgreSQL documentation about protection modes (https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-PROTECTION) and client connection parameters (https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLMODE).
        
        Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the PostgreSQL documentation (https://www.postgresql.org/docs/current/ssl-tcp.html) for details.
        
        4. Edit the `pg_hba.conf` configuration file to allow connections for the user `zbx_monitor`. You can check the PostgreSQL documentation for examples (https://www.postgresql.org/docs/current/auth-pg-hba-conf.html).
        
        5. Specify the host name or IP address in the `{$PG.HOST}` macro. Adjust the port number with `{$PG.PORT}` macro if needed.
        
        6. Set the password that you specified in step 1 in the macro `{$PG.PASSWORD}`.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384190-%C2%A0discussion-thread-for-official-zabbix-template-db-postgresql
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Overview
        
        This template is designed for the deployment of PostgreSQL monitoring by Zabbix via Zabbix agent and uses user parameters to run SQL queries with the `psql` command-line tool.
        
        ## Setup
        
        **Note:**
        - The template requires `pg_isready` and `psql` utilities to be installed on the same host with Zabbix agent.
        
        1. Create the PostgreSQL user for monitoring (`<password>` at your discretion) with proper access rights to your PostgreSQL instance.
        
        For PostgreSQL version 10 and above:
        
        ```sql
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
        GRANT pg_monitor TO zbx_monitor;
        ```
        
        For PostgreSQL version 9.6 and below:
        
        ```sql
        CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>';
        GRANT SELECT ON pg_stat_database TO zbx_monitor;
        
        -- To collect WAL metrics, the user must have a `superuser` role.
        ALTER USER zbx_monitor WITH SUPERUSER;
        ```
        
        2. Copy the `postgresql/` directory to the `zabbix` user home directory - `/var/lib/zabbix/`. The `postgresql/` directory contains the files with SQL queries needed to obtain metrics from PostgreSQL instance.
        
        If the home directory of the `zabbix` user doesn't exist, create it first:
        
        ```bash
        mkdir -m u=rwx,g=rwx,o= -p /var/lib/zabbix
        chown zabbix:zabbix /var/lib/zabbix
        ```
        
        3. Copy the `template_db_postgresql.conf` file, containing user parameters, to the Zabbix agent configuration directory `/etc/zabbix/zabbix_agentd.d/` and restart Zabbix agent service.
        
        **Note:** if you want to use SSL/TLS encryption to protect communications with the remote PostgreSQL instance, you can modify the connection string in user parameters. For example, to enable required encryption in transport mode without identity checks you could append `?sslmode=required` to the end of the connection string for all keys that use `psql`:
        
        ```bash
        UserParameter=pgsql.bgwriter[*], psql -qtAX postgresql://"$3":"$4"@"$1":"$2"/"$5"?sslmode=required -f "/var/lib/zabbix/postgresql/pgsql.bgwriter.sql"
        ```
        
        Consult the PostgreSQL documentation about [`protection modes`](https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-PROTECTION) and [`client connection parameters`](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLMODE).
        
        Also, it is assumed that you set up the PostgreSQL instance to work in the desired encryption mode. Check the [`PostgreSQL documentation`](https://www.postgresql.org/docs/current/ssl-tcp.html) for details.
        
        4. Edit the `pg_hba.conf` configuration file to allow connections for the user `zbx_monitor`. For example, you could add one of the following rows to allow local TCP connections from the same host:
        
        ```bash
        # TYPE  DATABASE        USER            ADDRESS                 METHOD
          host       all        zbx_monitor     localhost               trust
          host       all        zbx_monitor     127.0.0.1/32            md5
          host       all        zbx_monitor     ::1/128                 scram-sha-256
        ```
        
        For more information please read the PostgreSQL documentation `https://www.postgresql.org/docs/current/auth-pg-hba-conf.html`.
        
        5. Specify the host name or IP address in the `PostgreSQL host` host wizard configuration field. Adjust the port number in the `PostgreSQL port` field if needed.
        
        6. Set the password that you specified in step 1 in the `PostgreSQL user password` field.
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Databases
      items:
        - uuid: d469ec16aa434e3e82695d143abe479a
          name: 'Bgwriter: Buffers allocated per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_alloc.rate
          value_type: FLOAT
          description: 'Number of buffers allocated per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_alloc
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 511c3b3b363f43dd93746b3e0dad0f07
          name: 'Bgwriter: Buffers written directly by a backend per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_backend.rate
          value_type: FLOAT
          description: 'Number of buffers written directly by a backend per second. Available in PostgreSQL versions prior to 17.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_backend
              error_handler: DISCARD_VALUE
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 19795654aab941db8a95b092dda58737
          name: 'Bgwriter: Times a backend executed its own fsync per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_backend_fsync.rate
          value_type: FLOAT
          description: 'Number of times a backend had to execute its own fsync call per second (normally the background writer handles those even when the backend does its own write). Available in PostgreSQL versions prior to 17.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_backend_fsync
              error_handler: DISCARD_VALUE
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: a366775a3079422184cfac96f34173d6
          name: 'Checkpoint: Buffers written during checkpoints per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_checkpoint.rate
          value_type: FLOAT
          description: 'Number of buffers written during checkpoints per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_checkpoint
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 62598e17214f44888fa57db4214a3b5f
          name: 'Checkpoint: Buffers written by the background writer per second'
          type: DEPENDENT
          key: pgsql.bgwriter.buffers_clean.rate
          value_type: FLOAT
          description: 'Number of buffers written by the background writer per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.buffers_clean
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 6c05e2cb877142fe8b1c03ab6566a134
          name: 'Checkpoint: Requested per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoints_req.rate
          value_type: FLOAT
          description: 'Number of requested checkpoints that have been performed per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoints_req
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
          triggers:
            - uuid: 62699d1627fe4141ac59291b138b4f7e
              expression: 'last(/PostgreSQL by Zabbix agent active/pgsql.bgwriter.checkpoints_req.rate) > {$PG.CHECKPOINTS_REQ.MAX.WARN}'
              name: 'PostgreSQL: Required checkpoints occur too frequently'
              event_name: 'PostgreSQL: Required checkpoints occur too frequently (over {$PG.CHECKPOINTS_REQ.MAX.WARN})'
              priority: AVERAGE
              description: |
                Checkpoints are points in the sequence of transactions at which it is guaranteed that the heap and index data files have been updated with all information written before that checkpoint. At checkpoint time, all dirty data pages are flushed to disk and a special checkpoint record is written to the log file.
                https://www.postgresql.org/docs/current/wal-configuration.html
              tags:
                - tag: scope
                  value: performance
        - uuid: 9f4020e7f0294ffb9e15b75982be5a68
          name: 'Checkpoint: Scheduled per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoints_timed.rate
          value_type: FLOAT
          description: 'Number of scheduled checkpoints that have been performed per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoints_timed
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: bf59309e2fba4601920c64ab96f4d07e
          name: 'Checkpoint: Checkpoint sync time per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoint_sync_time.rate
          value_type: FLOAT
          units: s
          description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are synchronized to disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoint_sync_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 5bd159a9c2794486b0548f701605ccbc
          name: 'Checkpoint: Checkpoint write time per second'
          type: DEPENDENT
          key: pgsql.bgwriter.checkpoint_write_time.rate
          value_type: FLOAT
          units: s
          description: 'Total amount of time per second that has been spent in the portion of checkpoint processing where files are written to disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.checkpoint_write_time
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 716b6c5c1f304d17ad9784ebee2062e1
          name: 'Bgwriter: Number of bgwriter cleaning scan stopped per second'
          type: DEPENDENT
          key: pgsql.bgwriter.maxwritten_clean.rate
          value_type: FLOAT
          description: 'Number of times the background writer stopped a cleaning scan because it had written too many buffers per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.maxwritten_clean
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: bgwriter
        - uuid: 08043026cea14053a0addd4bdb7b7b8d
          name: 'Get bgwriter'
          type: ZABBIX_ACTIVE
          key: 'pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: 1h
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_bgwriter:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-BGWRITER-VIEW
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: 33ad0c74e4a34656bd911ebc2920e70a
              expression: 'nodata(/PostgreSQL by Zabbix agent active/pgsql.bgwriter["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],30m) = 1'
              name: 'PostgreSQL: Failed to get items'
              event_name: 'PostgreSQL: Failed to get items (no data for 30m)'
              priority: WARNING
              description: 'Zabbix has not received any data for items for the last 30 minutes.'
              dependencies:
                - name: 'PostgreSQL: Service is down'
                  expression: 'last(/PostgreSQL by Zabbix agent active/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 934e6647557f41cba46532a5a5c5d2ea
          name: 'Cache hit ratio, %'
          type: ZABBIX_ACTIVE
          key: 'pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          value_type: FLOAT
          units: '%'
          description: 'Cache hit ratio.'
          tags:
            - tag: component
              value: cache
          triggers:
            - uuid: bd2fd99b03b54916963dd661c959dd2f
              expression: 'max(/PostgreSQL by Zabbix agent active/pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) < {$PG.CACHE_HITRATIO.MIN.WARN}'
              name: 'PostgreSQL: Cache hit ratio too low'
              event_name: 'PostgreSQL: Cache hit ratio too low (under {$PG.CACHE_HITRATIO.MIN.WARN} in 5m)'
              priority: WARNING
              description: 'Cache hit ratio is lower than {$PG.CACHE_HITRATIO.MIN.WARN} for 5m.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 2d028578428949da8fa05d1f62f9f615
          name: 'Config hash'
          type: ZABBIX_ACTIVE
          key: 'pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 15m
          value_type: TEXT
          description: 'PostgreSQL configuration hash.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 483c370fa82f4c18ac9dbe7b07a4d7ff
              expression: 'last(/PostgreSQL by Zabbix agent active/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent active/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent active/pgsql.config.hash["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0'
              name: 'PostgreSQL: Configuration has changed'
              priority: INFO
              description: 'PostgreSQL configuration has changed.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 7866090bfc5d4e1db50b50957b372685
          name: 'Connections sum: Active'
          type: DEPENDENT
          key: pgsql.connections.sum.active
          description: 'Total number of connections executing a query.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.active
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 7853f5db0cc54865ba0fc3323b4b9810
          name: 'Connections sum: Idle'
          type: DEPENDENT
          key: pgsql.connections.sum.idle
          description: 'Total number of connections waiting for a new client command.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: b609844ba35149e2a92e43ce5aa4c6f1
          name: 'Connections sum: Idle in transaction'
          type: DEPENDENT
          key: pgsql.connections.sum.idle_in_transaction
          description: 'Total number of connections in a transaction state but not executing a query.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle_in_transaction
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: dc8be28daed141c789beab5e7c64c660
          name: 'Connections sum: Prepared'
          type: DEPENDENT
          key: pgsql.connections.sum.prepared
          description: |
            Total number of prepared transactions:
            https://www.postgresql.org/docs/current/sql-prepare-transaction.html
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.prepared
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: c04d920d78e54039bca114e94c655a17
          name: 'Connections sum: Total'
          type: DEPENDENT
          key: pgsql.connections.sum.total
          description: 'Total number of connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: ea0eaf2f784f476e9ce72fa119f8badb
          name: 'Connections sum: Total, %'
          type: DEPENDENT
          key: pgsql.connections.sum.total_pct
          units: '%'
          description: 'Total number of connections, in percentage.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.total_pct
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
          triggers:
            - uuid: b4673d7606514a6cb5b3ef61b5b05ce1
              expression: 'min(/PostgreSQL by Zabbix agent active/pgsql.connections.sum.total_pct,5m) > {$PG.CONN_TOTAL_PCT.MAX.WARN}'
              name: 'PostgreSQL: Total number of connections is too high'
              event_name: 'PostgreSQL: Total number of connections is too high (over {$PG.CONN_TOTAL_PCT.MAX.WARN} in 5m)'
              priority: AVERAGE
              description: 'Total number of current connections exceeds the limit of {$PG.CONN_TOTAL_PCT.MAX.WARN}% out of the maximum number of concurrent connections to the database server (the "max_connections" setting).'
              tags:
                - tag: scope
                  value: performance
        - uuid: e19ab5dbf64348158c6033073c1a1058
          name: 'Connections sum: Waiting'
          type: DEPENDENT
          key: pgsql.connections.sum.waiting
          description: |
            Total number of waiting connections:
            https://www.postgresql.org/docs/current/monitoring-stats.html#WAIT-EVENT-TABLE
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.waiting
          master_item:
            key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: connections
        - uuid: 13cce1cb170f4c9db977cb49fc603f79
          name: 'Get connections sum'
          type: ZABBIX_ACTIVE
          key: 'pgsql.connections.sum["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_activity:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: bea2e947b16b4a3dac660e664a505904
          name: 'Get dbstat'
          type: ZABBIX_ACTIVE
          key: 'pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_stat_database per database:
            https://www.postgresql.org/docs/current/monitoring-stats.html#PG-STAT-DATABASE-VIEW
          tags:
            - tag: component
              value: raw
        - uuid: e5adbe1c2fc74943926cf45ff5efbff3
          name: 'Get locks'
          type: ZABBIX_ACTIVE
          key: 'pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: |
            Collect all metrics from pg_locks per database:
            https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-TABLES
          tags:
            - tag: component
              value: raw
        - uuid: 2ab77e9548014233b0945bdeb9c134bd
          name: 'Ping time'
          type: ZABBIX_ACTIVE
          key: 'pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          value_type: FLOAT
          units: s
          description: 'Used to get the `SELECT 1` query execution time.'
          preprocessing:
            - type: REGEX
              parameters:
                - 'Time:\s+(\d+\.\d+)\s+ms'
                - \1
            - type: MULTIPLIER
              parameters:
                - '0.001'
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: 0b54c409159f494c969c040d295b5cfb
              expression: 'min(/PostgreSQL by Zabbix agent active/pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) > {$PG.PING_TIME.MAX.WARN}'
              name: 'PostgreSQL: Response too long'
              event_name: 'PostgreSQL: Response too long (over {$PG.PING_TIME.MAX.WARN})'
              priority: AVERAGE
              description: 'Response is taking too long (over {$PG.PING_TIME.MAX.WARN} for 5m).'
              dependencies:
                - name: 'PostgreSQL: Service is down'
                  expression: 'last(/PostgreSQL by Zabbix agent active/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0'
              tags:
                - tag: scope
                  value: availability
                - tag: scope
                  value: performance
        - uuid: 058b3cd8308b4692a5cb3e89a47886bd
          name: Ping
          type: ZABBIX_ACTIVE
          key: 'pgsql.ping["{$PG.HOST}","{$PG.PORT}"]'
          description: 'Used to test a connection to see if it is alive. It is set to 0 if the instance doesn''t accept the connections.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return value.search(/accepting connections/)>0 ? 1 : 0'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: 32a43d55902d46b09f602dc89e3a2586
              expression: 'last(/PostgreSQL by Zabbix agent active/pgsql.ping["{$PG.HOST}","{$PG.PORT}"]) = 0'
              name: 'PostgreSQL: Service is down'
              priority: HIGH
              description: 'Last test of a connection was unsuccessful.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 2a4de36d7b434260b264a63ab444a430
          name: 'Get queries'
          type: ZABBIX_ACTIVE
          key: 'pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"]'
          history: '0'
          value_type: TEXT
          description: 'Collect all metrics by query execution time.'
          tags:
            - tag: component
              value: raw
        - uuid: 401331b4eab0439ca954551bce2f0c2e
          name: 'Replication: Standby count'
          type: ZABBIX_ACTIVE
          key: 'pgsql.replication.count["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Number of standby servers.'
          tags:
            - tag: component
              value: replication
        - uuid: 2005dff88ab64458b3970a40e5bf0aff
          name: 'Replication: Lag in seconds'
          type: ZABBIX_ACTIVE
          key: 'pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          units: s
          description: 'Replication lag with master, in seconds.'
          tags:
            - tag: component
              value: replication
          triggers:
            - uuid: 99adc9f76c0b42a08c22271b9206ce18
              expression: 'min(/PostgreSQL by Zabbix agent active/pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m) > {$PG.REPL_LAG.MAX.WARN}'
              name: 'PostgreSQL: Streaming lag with master is too high'
              event_name: 'PostgreSQL: Streaming lag with master is too high (over {$PG.REPL_LAG.MAX.WARN} in 5m)'
              priority: AVERAGE
              description: 'Replication lag with master is higher than {$PG.REPL_LAG.MAX.WARN} for 5m.'
              tags:
                - tag: scope
                  value: availability
                - tag: scope
                  value: performance
        - uuid: 808f71865b934ac68512a3d6fa8b4aab
          name: 'Replication: Recovery role'
          type: ZABBIX_ACTIVE
          key: 'pgsql.replication.recovery_role["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Replication role: 1 — recovery is still in progress (standby mode), 0 — master mode.'
          valuemap:
            name: 'PostgreSQL recovery role'
          tags:
            - tag: component
              value: replication
        - uuid: 5c4061c4081d41fa86741a296378d031
          name: 'Replication: Status'
          type: ZABBIX_ACTIVE
          key: 'pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          description: 'Replication status: 0 — streaming is down, 1 — streaming is up, 2 — master mode.'
          valuemap:
            name: 'PostgreSQL replication status'
          tags:
            - tag: component
              value: replication
          triggers:
            - uuid: 63b498ebd0484bc59f701e4179ed4fb2
              expression: 'max(/PostgreSQL by Zabbix agent active/pgsql.replication.status["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],5m)=0'
              name: 'PostgreSQL: Replication is down'
              priority: AVERAGE
              description: 'Replication is enabled and data streaming was down for 5m.'
              tags:
                - tag: scope
                  value: availability
        - uuid: ecbeae6a23e74cc89c670daf60f81833
          name: 'Transactions: Max active transaction time'
          type: DEPENDENT
          key: pgsql.transactions.active
          value_type: FLOAT
          units: s
          description: 'Current max active transaction time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.active
          master_item:
            key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: 406d76761c0b4e0dbe83a14f48874fed
          name: 'Transactions: Max idle transaction time'
          type: DEPENDENT
          key: pgsql.transactions.idle
          value_type: FLOAT
          units: s
          description: 'Current max idle transaction time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.idle
          master_item:
            key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: 3e0f09be15284811a4f9864be8aaa1e7
          name: 'Transactions: Max prepared transaction time'
          type: DEPENDENT
          key: pgsql.transactions.prepared
          value_type: FLOAT
          units: s
          description: 'Current max prepared transaction time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.prepared
          master_item:
            key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: 2c5f5402e73942ef9a51d7965b9e705b
          name: 'Transactions: Max waiting transaction time'
          type: DEPENDENT
          key: pgsql.transactions.waiting
          value_type: FLOAT
          units: s
          description: 'Current max waiting transaction time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.waiting
          master_item:
            key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: transactions
        - uuid: b22ed1707bd84c4faa010803b2c594fa
          name: 'Get transactions'
          type: ZABBIX_ACTIVE
          key: 'pgsql.transactions["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          history: '0'
          value_type: TEXT
          description: 'Collect metrics by transaction execution time.'
          tags:
            - tag: component
              value: raw
        - uuid: d310b47d3e38466a980494fb0f9dfb01
          name: Uptime
          type: ZABBIX_ACTIVE
          key: 'pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          units: uptime
          description: 'Time since the server started.'
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: a7c05ccff4c342018777471d1f3a17b7
              expression: 'last(/PostgreSQL by Zabbix agent active/pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]) < 10m'
              name: 'PostgreSQL: Service has been restarted'
              event_name: 'PostgreSQL: Service has been restarted (uptime < 10m)'
              priority: AVERAGE
              description: 'PostgreSQL uptime is less than 10 minutes.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 9798496e21914a8cbdee1cd85decf3e8
          name: Version
          type: ZABBIX_ACTIVE
          key: 'pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 15m
          value_type: CHAR
          description: 'PostgreSQL version.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: e06391b8cfe74fb5ad3b3bb2718b5e58
              expression: 'last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#1)<>last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"],#2) and length(last(/PostgreSQL by Zabbix agent active/pgsql.version["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]))>0'
              name: 'PostgreSQL: Version has changed'
              event_name: 'PostgreSQL: Version has changed (new version value received: {ITEM.VALUE})'
              priority: INFO
              tags:
                - tag: scope
                  value: notice
        - uuid: b1c6d3ff86f240df8f2c3a14a47e4df1
          name: 'WAL: Segments count'
          type: DEPENDENT
          key: pgsql.wal.count
          description: 'Number of WAL segments.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.count
          master_item:
            key: 'pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: wal
        - uuid: 9ca8653ea8304b5392d1c39111381751
          name: 'Get WAL'
          type: ZABBIX_ACTIVE
          key: 'pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 5m
          history: '0'
          value_type: TEXT
          description: 'Collect write-ahead log (WAL) metrics.'
          tags:
            - tag: component
              value: raw
        - uuid: 08580207e58142a393e310b0d592a7d5
          name: 'WAL: Bytes written'
          type: DEPENDENT
          key: pgsql.wal.write
          units: B
          description: 'WAL write, in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.write
            - type: CHANGE_PER_SECOND
          master_item:
            key: 'pgsql.wal.stat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          tags:
            - tag: component
              value: wal
      discovery_rules:
        - uuid: d9625ea888804a8b82d395e1e002c6cd
          name: 'Database discovery'
          type: ZABBIX_ACTIVE
          key: 'pgsql.discovery.db["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
          delay: 1h
          filter:
            conditions:
              - macro: '{#DBNAME}'
                value: '{$PG.LLD.FILTER.DBNAME}'
          description: |
            Discovers databases (DB) in the database management system (DBMS), except:
            - templates;
            - default "postgres" DB;
            - DBs that do not allow connections.
          item_prototypes:
            - uuid: f8d430b69f4f4f2aa04e2906cc4ab3cd
              name: 'DB [{#DBNAME}]: Database size'
              type: ZABBIX_ACTIVE
              key: 'pgsql.db.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#DBNAME}"]'
              delay: 15m
              units: B
              description: 'Database size.'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: aa8e864297914f25bb6cc6b914871a46
              name: 'DB [{#DBNAME}]: Blocks hit per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of times per second disk blocks were found already in the buffer cache, so that a read was not necessary.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blks_hit
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: cache
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 69d6cc93dbff4669a18b6e12fb6e8b7a
              name: 'DB [{#DBNAME}]: Disk blocks read per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of disk blocks read per second in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blks_read
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 8894ff8a7e4641559efd456a9024ef9a
              name: 'DB [{#DBNAME}]: Detected conflicts per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of queries canceled due to conflicts with recovery in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.conflicts
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: e35f79c06fba41dfb9d9c35e4a13a043
                  expression: 'min(/PostgreSQL by Zabbix agent active/pgsql.dbstat.conflicts.rate["{#DBNAME}"],5m) > {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Too many recovery conflicts (over {$PG.CONFLICTS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: AVERAGE
                  description: |
                    The primary and standby servers are in many ways loosely connected. Actions on the primary will have an effect on the standby. As a result, there is potential for negative interactions or conflicts between them.
                    https://www.postgresql.org/docs/current/hot-standby.html#HOT-STANDBY-CONFLICT
                  tags:
                    - tag: scope
                      value: performance
            - uuid: 8a3dfbedb1f54b93bc6ca90d9476677c
              name: 'DB [{#DBNAME}]: Detected deadlocks per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of detected deadlocks in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.deadlocks
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: deadlocks
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 5243a46334674a06b52efdef93bce0ec
                  expression: 'min(/PostgreSQL by Zabbix agent active/pgsql.dbstat.deadlocks.rate["{#DBNAME}"],5m) > {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Deadlock occurred'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Deadlock occurred (over {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: HIGH
                  description: 'Number of deadlocks detected per second exceeds {$PG.DEADLOCKS.MAX.WARN:"{#DBNAME}"} for 5m.'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: f7a0b95d306542ddb8b9730650f4fc27
              name: 'DB [{#DBNAME}]: Get dbstat'
              type: DEPENDENT
              key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get dbstat metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.dbstat["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: eabd8d2f4a9d4a48be75d0d56eb48e17
              name: 'DB [{#DBNAME}]: Temp_bytes written per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
              units: B
              description: 'Total amount of data written to temporary files by queries in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.temp_bytes
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 51288ac46f5c49ae8cafe421bbb41d29
              name: 'DB [{#DBNAME}]: Temp_files created per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
              description: 'Total number of temporary files created by queries in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.temp_files
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 7ad48d3b888a4f24a091a597e3189fee
              name: 'DB [{#DBNAME}]: Tuples deleted per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows deleted by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_deleted
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: c0688782315f49aba4a468d9d0bac3e6
              name: 'DB [{#DBNAME}]: Tuples fetched per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows fetched by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_fetched
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 308fc84decc04b738d3e00cdf8427164
              name: 'DB [{#DBNAME}]: Tuples inserted per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows inserted by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_inserted
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 42125b8816044bc09ec4904ea78402b0
              name: 'DB [{#DBNAME}]: Tuples returned per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of rows returned by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_returned
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 495797c1a134404d88c4216aebff3f28
              name: 'DB [{#DBNAME}]: Tuples updated per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of rows updated by queries in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tup_updated
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 88b787af729944e8b262ca99dcefe8a3
              name: 'DB [{#DBNAME}]: Commits per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of transactions in this database that have been committed per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.xact_commit
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 2f31f5f8b36c4742b9a74862b17b30c0
              name: 'DB [{#DBNAME}]: Rollbacks per second'
              type: DEPENDENT
              key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Total number of transactions in this database that have been rolled back.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.xact_rollback
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.dbstat.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 50147f7140144de2af4200b9be95535a
              name: 'DB [{#DBNAME}]: Frozen XID before autovacuum, %'
              type: DEPENDENT
              key: 'pgsql.frozenxid.prc_before_av["{#DBNAME}"]'
              value_type: FLOAT
              units: '%'
              description: |
                Preventing Transaction ID Wraparound Failures:
                https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.prc_before_av
              master_item:
                key: 'pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 2cf70e1bfa084b92b7155a1f41351069
              name: 'DB [{#DBNAME}]: Frozen XID before stop, %'
              type: DEPENDENT
              key: 'pgsql.frozenxid.prc_before_stop["{#DBNAME}"]'
              value_type: FLOAT
              units: '%'
              description: |
                Preventing Transaction ID Wraparound Failures:
                https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.prc_before_stop
              master_item:
                key: 'pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 0c207f7271ad4df19977722a976b8ccc
                  expression: 'last(/PostgreSQL by Zabbix agent active/pgsql.frozenxid.prc_before_stop["{#DBNAME}"])<{$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: VACUUM FREEZE is required to prevent wraparound (frozen XID less than {$PG.FROZENXID_PCT_STOP.MIN.HIGH:"{#DBNAME}"} %)'
                  priority: AVERAGE
                  description: |
                    Preventing Transaction ID Wraparound Failures:
                    https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 2e0e02f98b3c45d195f93e1ed8ec343d
              name: 'DB [{#DBNAME}]: Get frozen XID'
              type: ZABBIX_ACTIVE
              key: 'pgsql.frozenxid["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 220503c9eeac46ea8656f7b5a149c29d
              name: 'DB [{#DBNAME}]: Num of locks total'
              type: DEPENDENT
              key: 'pgsql.locks.total["{#DBNAME}"]'
              description: 'Total number of locks in this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}''].total'
              master_item:
                key: 'pgsql.locks["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
              tags:
                - tag: component
                  value: locks
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: 7a235edcda5d4482a9a3f3e5d741ee6e
                  expression: 'min(/PostgreSQL by Zabbix agent active/pgsql.locks.total["{#DBNAME}"],5m)>{$PG.LOCKS.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Number of locks is too high'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Number of locks is too high (over {$PG.LOCKS.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: WARNING
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 1e31cbe913ef44b1896fc44cf11cb18c
              name: 'DB [{#DBNAME}]: Get queries'
              type: DEPENDENT
              key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Get queries metrics for database "{#DBNAME}".'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[''{#DBNAME}'']'
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'pgsql.queries["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{$PG.QUERY_ETIME.MAX.WARN}"]'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
            - uuid: ed9c08ef16c845c08788de774405cbeb
              name: 'DB [{#DBNAME}]: Queries slow maintenance count'
              type: DEPENDENT
              key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
              description: 'Slow maintenance query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: a405b92ed32c4424a4e0136016370da4
              name: 'DB [{#DBNAME}]: Queries max maintenance time'
              type: DEPENDENT
              key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
              units: s
              description: 'Max maintenance query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 58406e650bf74db2ab216d35f4ef8f60
              name: 'DB [{#DBNAME}]: Queries sum maintenance time'
              type: DEPENDENT
              key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum maintenance query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.mro_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 04b8af083191408284aab798ed5c2ac4
              name: 'DB [{#DBNAME}]: Queries slow query count'
              type: DEPENDENT
              key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
              description: 'Slow query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
              trigger_prototypes:
                - uuid: fe5e595cd37c40c3b99aa28a12575b3d
                  expression: 'min(/PostgreSQL by Zabbix agent active/pgsql.queries.query.slow_count["{#DBNAME}"],5m)>{$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}'
                  name: 'PostgreSQL: DB [{#DBNAME}]: Too many slow queries'
                  event_name: 'PostgreSQL: DB [{#DBNAME}]: Too many slow queries (over {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"} in 5m)'
                  priority: WARNING
                  description: 'The number of detected slow queries exceeds the limit of {$PG.SLOW_QUERIES.MAX.WARN:"{#DBNAME}"}.'
                  tags:
                    - tag: scope
                      value: performance
            - uuid: d47d6e5857534981aeb5e92ef6423c7d
              name: 'DB [{#DBNAME}]: Queries max query time'
              type: DEPENDENT
              key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
              units: s
              description: 'Max query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: a5c184f0d7c74a52983cccb836fe3d61
              name: 'DB [{#DBNAME}]: Queries sum query time'
              type: DEPENDENT
              key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.query_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 4b71f7bbc17c4695beb75cfc9bc67da0
              name: 'DB [{#DBNAME}]: Queries slow transaction count'
              type: DEPENDENT
              key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
              description: 'Slow transaction query count for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_slow_count
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 5489fc69a7ce45a0a0c0cff565a62189
              name: 'DB [{#DBNAME}]: Queries max transaction time'
              type: DEPENDENT
              key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
              units: s
              description: 'Max transaction query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_time_max
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 3283a1520f1b4adabf01964efdaaa31c
              name: 'DB [{#DBNAME}]: Queries sum transaction time'
              type: DEPENDENT
              key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
              units: s
              description: 'Sum transaction query time for this database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_time_sum
              master_item:
                key: 'pgsql.queries.get_metrics["{#DBNAME}"]'
              tags:
                - tag: component
                  value: queries
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 7e7e322396c24c70bb479ae84b79bbcd
              name: 'DB [{#DBNAME}]: Index scans per second'
              type: DEPENDENT
              key: 'pgsql.scans.idx.rate["{#DBNAME}"]'
              description: 'Number of index scans in the database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.idx
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: scans
                - tag: database
                  value: '{#DBNAME}'
            - uuid: c64cdbfa58994f699fb7ad7c3fd38b5f
              name: 'DB [{#DBNAME}]: Sequential scans per second'
              type: DEPENDENT
              key: 'pgsql.scans.seq.rate["{#DBNAME}"]'
              value_type: FLOAT
              description: 'Number of sequential scans in this database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.seq
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              tags:
                - tag: component
                  value: scans
                - tag: database
                  value: '{#DBNAME}'
            - uuid: 8ee891f2e0ae4c74a24ebffc67380f01
              name: 'DB [{#DBNAME}]: Get scans'
              type: ZABBIX_ACTIVE
              key: 'pgsql.scans["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{#DBNAME}"]'
              history: '0'
              value_type: TEXT
              description: 'Number of scans done for table/index in this database.'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DBNAME}'
          graph_prototypes:
            - uuid: 692254ddbb2646ed8f8f73e28d400d28
              name: 'DB [{#DBNAME}]: Block hit/read'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.blks_hit.rate["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.blks_read.rate["{#DBNAME}"]'
            - uuid: 0faea1cf0ef4422cabc9af14f3e774e9
              name: 'DB [{#DBNAME}]: Database size'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.db.size["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}","{#DBNAME}"]'
            - uuid: 61a7e55b8e614ae58a5e8675babba974
              name: 'DB [{#DBNAME}]: Events'
              ymin_type_1: FIXED
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.xact_commit.rate["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.conflicts.rate["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.deadlocks.rate["{#DBNAME}"]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.xact_rollback.rate["{#DBNAME}"]'
            - uuid: 1ef3d8b8ac0d48d9b19551ceb60de933
              name: 'DB [{#DBNAME}]: Locks'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.locks.total["{#DBNAME}"]'
            - uuid: 27541a985dc04626836b8c11a038f328
              name: 'DB [{#DBNAME}]: Queries'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.queries.mro.time_max["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.queries.query.time_max["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.queries.tx.time_max["{#DBNAME}"]'
                - sortorder: '3'
                  drawtype: GRADIENT_LINE
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.queries.mro.time_sum["{#DBNAME}"]'
                - sortorder: '4'
                  drawtype: GRADIENT_LINE
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.queries.query.time_sum["{#DBNAME}"]'
                - sortorder: '5'
                  drawtype: GRADIENT_LINE
                  color: 6C59DC
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.queries.tx.time_sum["{#DBNAME}"]'
            - uuid: 7d858a9a047b453096471773f8a31063
              name: 'DB [{#DBNAME}]: Slow queries'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.queries.mro.slow_count["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.queries.query.slow_count["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.queries.tx.slow_count["{#DBNAME}"]'
            - uuid: 806181664b4b4e44b28a099b0281edad
              name: 'DB [{#DBNAME}]: Temp files'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.temp_bytes.rate["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  yaxisside: RIGHT
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.temp_files.rate["{#DBNAME}"]'
            - uuid: e652d9ffb74b4abab75f811dd696bf21
              name: 'DB [{#DBNAME}]: Tuples'
              ymin_type_1: FIXED
              graph_items:
                - color: 199C0D
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.tup_deleted.rate["{#DBNAME}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.tup_fetched.rate["{#DBNAME}"]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.tup_inserted.rate["{#DBNAME}"]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.tup_returned.rate["{#DBNAME}"]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'PostgreSQL by Zabbix agent active'
                    key: 'pgsql.dbstat.tup_updated.rate["{#DBNAME}"]'
      tags:
        - tag: class
          value: database
        - tag: subclass
          value: sql
        - tag: target
          value: postgresql
      macros:
        - macro: '{$PG.CACHE_HITRATIO.MIN.WARN}'
          value: '90'
          description: 'Minimum cache hit ratio percentage for trigger expression.'
          config:
            type: TEXT
            priority: '12'
            section_name: Thresholds
            label: 'Minimum cache hit ratio percentage'
            description: 'Minimum cache hit ratio percentage for trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.CHECKPOINTS_REQ.MAX.WARN}'
          value: '5'
          description: 'Maximum required checkpoint occurrences for trigger expression.'
          config:
            type: TEXT
            priority: '13'
            section_name: Thresholds
            label: 'Maximum required checkpoint occurrences'
            description: 'Maximum required checkpoint occurrences for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.CONFLICTS.MAX.WARN}'
          value: '0'
          description: 'Maximum number of recovery conflicts for trigger expression.'
          config:
            type: TEXT
            priority: '17'
            section_name: Thresholds
            label: 'Maximum number of recovery conflicts'
            description: 'Maximum number of recovery conflicts for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.CONN_TOTAL_PCT.MAX.WARN}'
          value: '90'
          description: 'Maximum percentage of current connections for trigger expression.'
          config:
            type: TEXT
            priority: '14'
            section_name: Thresholds
            label: 'Maximum percentage of current connections'
            description: 'Maximum percentage of current connections for trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.DATABASE}'
          value: postgres
          description: 'Default PostgreSQL database for the connection.'
          config:
            type: TEXT
            priority: '5'
            label: 'Default PostgreSQL database for the connection'
            required: 'YES'
        - macro: '{$PG.DEADLOCKS.MAX.WARN}'
          value: '0'
          description: 'Maximum number of detected deadlocks for trigger expression.'
          config:
            type: TEXT
            priority: '15'
            section_name: Thresholds
            label: 'Maximum number of detected deadlocks'
            description: 'Maximum number of detected deadlocks for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.FROZENXID_PCT_STOP.MIN.HIGH}'
          value: '75'
          description: 'Minimum frozen XID before stop percentage for trigger expression.'
          config:
            type: TEXT
            priority: '16'
            section_name: Thresholds
            label: 'Minimum frozen XID before stop percentage'
            description: 'Minimum frozen XID before stop percentage for trigger expression. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.HOST}'
          value: localhost
          description: 'Hostname or IP of PostgreSQL host.'
          config:
            type: TEXT
            priority: '1'
            label: 'PostgreSQL host'
            description: 'Hostname or IP of PostgreSQL host.'
            required: 'YES'
        - macro: '{$PG.LLD.FILTER.DBNAME}'
          value: .+
          description: 'Filter of discoverable databases.'
          config:
            type: TEXT
            priority: '6'
            section_name: Filters
            label: 'Database name LLD filter'
            description: 'Filter of discoverable databases.'
        - macro: '{$PG.LOCKS.MAX.WARN}'
          value: '100'
          description: 'Maximum number of locks for trigger expression.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Maximum number of locks'
            description: 'Maximum number of locks for trigger expression. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.PASSWORD}'
          type: SECRET_TEXT
          description: 'PostgreSQL user password.'
          config:
            type: TEXT
            priority: '4'
            label: 'PostgreSQL user password'
            required: 'YES'
        - macro: '{$PG.PING_TIME.MAX.WARN}'
          value: 1s
          description: 'Maximum time of connection response for trigger expression.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Maximum time of connection response'
            description: 'Maximum time of connection response for trigger expression.'
        - macro: '{$PG.PORT}'
          value: '5432'
          description: 'PostgreSQL service port.'
          config:
            type: TEXT
            priority: '2'
            label: 'PostgreSQL port'
            description: 'PostgreSQL service port. In the range from 1 to 65535 inclusive.'
            required: 'YES'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.QUERY_ETIME.MAX.WARN}'
          value: '30'
          description: 'Execution time limit for count of slow queries.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Slow queries execution time threshold'
            description: 'Execution time threshold for queries to be considered slow. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.REPL_LAG.MAX.WARN}'
          value: 10m
          description: 'Maximum replication lag time for trigger expression.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'Maximum replication lag time'
            description: 'Maximum replication lag time for trigger expression.'
        - macro: '{$PG.SLOW_QUERIES.MAX.WARN}'
          value: '5'
          description: 'Slow queries count threshold for a trigger.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'Slow queries count threshold'
            description: 'Slow queries count threshold for a trigger. No less than 0.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$PG.USER}'
          value: zbx_monitor
          description: 'PostgreSQL username.'
          config:
            type: TEXT
            priority: '3'
            label: 'PostgreSQL username'
            required: 'YES'
      dashboards:
        - uuid: 1311b2e221bf4de49c394bf689333810
          name: 'PostgreSQL databases'
          pages:
            - widgets:
                - type: graphprototype
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'DB [{#DBNAME}]: Tuples'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graphprototype
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'DB [{#DBNAME}]: Block hit/read'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graphprototype
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'DB [{#DBNAME}]: Locks'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: graphprototype
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'DB [{#DBNAME}]: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graphprototype
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'DB [{#DBNAME}]: Events'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graphprototype
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'DB [{#DBNAME}]: Temp files'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graphprototype
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'DB [{#DBNAME}]: Database size'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graphprototype
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'DB [{#DBNAME}]: Slow queries'
                    - type: STRING
                      name: reference
                      value: AAAAH
        - uuid: 2d6268f99f9748d18cb0bb4aee1fc550
          name: 'PostgreSQL stat'
          pages:
            - widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'PostgreSQL connections'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'PostgreSQL ping'
                    - type: STRING
                      name: reference
                      value: AAAAK
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'PostgreSQL replication lag'
                    - type: STRING
                      name: reference
                      value: AAAAM
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'PostgreSQL bgwriter'
                    - type: STRING
                      name: reference
                      value: AAAAO
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'PostgreSQL transactions'
                    - type: STRING
                      name: reference
                      value: AAAAJ
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'PostgreSQL uptime'
                    - type: STRING
                      name: reference
                      value: AAAAL
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'PostgreSQL WAL'
                    - type: STRING
                      name: reference
                      value: AAAAN
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PostgreSQL by Zabbix agent active'
                        name: 'PostgreSQL checkpoints'
                    - type: STRING
                      name: reference
                      value: AAAAP
      valuemaps:
        - uuid: 6337031a50574f65aec828b7dd48beaf
          name: 'PostgreSQL recovery role'
          mappings:
            - value: '0'
              newvalue: Master
            - value: '1'
              newvalue: Standby
        - uuid: 0e115837e8c54923ad10a9b7adcda3dd
          name: 'PostgreSQL replication status'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
            - value: '2'
              newvalue: Master
        - uuid: 5bc68afd88094e0fb14572246050181f
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
  triggers:
    - uuid: a1397bd4e9334a24a34dba0687b263e6
      expression: 'last(/MSSQL by ODBC/mssql.forwarded_records_sec.rate) * 100 > 10 * last(/MSSQL by ODBC/mssql.batch_requests_sec.rate)'
      name: 'MSSQL: Too frequently using pointers'
      priority: WARNING
      description: 'Rows with VARCHAR columns can experience expansion when VARCHAR values are updated with a longer string. In the case where the row cannot fit in the existing page, the row migrates, and access to the row will traverse a pointer. This only happens on heaps (tables without clustered indexes). In cases where clustered indexes cannot be used, drop non-clustered indexes, build a clustered index to reorg pages and rows, drop the clustered index, then recreate non-clustered indexes.'
      tags:
        - tag: scope
          value: performance
    - uuid: 366fa3cfcba94e038ad77c2f5a2649a2
      expression: 'last(/MSSQL by Zabbix agent 2/mssql.forwarded_records_sec.rate) * 100 > 10 * last(/MSSQL by Zabbix agent 2/mssql.batch_requests_sec.rate)'
      name: 'MSSQL: Too frequently using pointers'
      priority: WARNING
      description: 'Rows with VARCHAR columns can experience expansion when VARCHAR values are updated with a longer string. In the case where the row cannot fit in the existing page, the row migrates, and access to the row will traverse a pointer. This only happens on heaps (tables without clustered indexes). In cases where clustered indexes cannot be used, drop non-clustered indexes, build a clustered index to reorg pages and rows, drop the clustered index, then recreate non-clustered indexes.'
      tags:
        - tag: scope
          value: performance
    - uuid: 2a58729eb605461b853ec4e855878226
      expression: 'last(/MSSQL by ODBC/mssql.readahead_pages_sec.rate) > {$MSSQL.PERCENT_READAHEAD.MAX} / 100 * last(/MSSQL by ODBC/mssql.page_reads_sec.rate)'
      name: 'MSSQL: Too many physical reads occurring'
      priority: WARNING
      description: 'If this value makes up even a sizeable minority of the total "Page Reads/sec" (say, greater than 20% of the total page reads), you may have too many physical reads occurring.'
      tags:
        - tag: scope
          value: performance
    - uuid: 274773f4bb9d4af798e8922b5054226b
      expression: 'last(/MSSQL by Zabbix agent 2/mssql.readahead_pages_sec.rate) > {$MSSQL.PERCENT_READAHEAD.MAX} / 100 * last(/MSSQL by Zabbix agent 2/mssql.page_reads_sec.rate)'
      name: 'MSSQL: Too many physical reads occurring'
      priority: WARNING
      description: 'If this value makes up even a sizeable minority of the total "Page Reads/sec" (say, greater than 20% of the total page reads), you may have too many physical reads occurring.'
      tags:
        - tag: scope
          value: performance
    - uuid: 7b0bde98c6c54e67b0aa8b3339fe464d
      expression: 'max(/Oracle by ODBC/net.tcp.service[tcp,{$ORACLE.HOST},{$ORACLE.PORT}],#3)=0  and max(/Oracle by ODBC/proc.num[,,,"tnslsnr LISTENER"],#3)>0'
      name: 'Oracle: Port {$ORACLE.PORT} is unavailable'
      priority: DISASTER
      description: 'The TCP port of the Oracle Server service is currently unavailable.'
      tags:
        - tag: scope
          value: availability
    - uuid: 38471058988c46f4b81af9f77637914a
      expression: 'min(/Oracle by ODBC/oracle.processes_count,5m) * 100 / last(/Oracle by ODBC/oracle.processes_limit) > {$ORACLE.PROCESSES.MAX.WARN}'
      name: 'Oracle: Too many active processes'
      event_name: 'Oracle: Too many active processes (over {$ORACLE.PROCESSES.MAX.WARN}% for 5 min)'
      priority: WARNING
      description: 'Active processes are using more than `{$ORACLE.PROCESSES.MAX.WARN}`% of the available number of processes.'
      tags:
        - tag: scope
          value: capacity
    - uuid: 3f265c15b3d042d79b1aa598f7249738
      expression: 'min(/Oracle by Zabbix agent 2/oracle.proc.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"],5m) * 100 / last(/Oracle by Zabbix agent 2/oracle.processes_limit) > {$ORACLE.PROCESSES.MAX.WARN}'
      name: 'Oracle: Too many active processes'
      event_name: 'Oracle: Too many active processes (over {$ORACLE.PROCESSES.MAX.WARN}% for 5 min)'
      priority: WARNING
      description: 'Active processes are using more than `{$ORACLE.PROCESSES.MAX.WARN}`% of the available number of processes.'
      tags:
        - tag: scope
          value: capacity
    - uuid: 4a055da31f09489ea0f03e4582ee4333
      expression: 'min(/Oracle by ODBC/oracle.session_count,5m) * 100 / last(/Oracle by ODBC/oracle.session_limit) > {$ORACLE.SESSIONS.MAX.WARN}'
      name: 'Oracle: Too many active sessions'
      event_name: 'Oracle: Too many active sessions (over {$ORACLE.SESSIONS.MAX.WARN}% for 5 min)'
      priority: WARNING
      description: 'Active sessions are using more than `{$ORACLE.SESSIONS.MAX.WARN}`% of the available sessions.'
      tags:
        - tag: scope
          value: capacity
    - uuid: d9977c48c6e7435eafde4cabc43bb5fc
      expression: 'min(/Oracle by Zabbix agent 2/oracle.session_count,5m) * 100 / last(/Oracle by Zabbix agent 2/oracle.session_limit) > {$ORACLE.SESSIONS.MAX.WARN}'
      name: 'Oracle: Too many active sessions'
      event_name: 'Oracle: Too many active sessions (over {$ORACLE.SESSIONS.MAX.WARN}% for 5 min)'
      priority: WARNING
      description: 'Active sessions are using more than `{$ORACLE.SESSIONS.MAX.WARN}`% of the available sessions.'
      tags:
        - tag: scope
          value: capacity
    - uuid: 5752d92063f84aaa818bc85b135cd4fd
      expression: 'min(/Oracle by ODBC/oracle.db_files_count,5m) * 100 / last(/Oracle by ODBC/oracle.db_files_limit) > {$ORACLE.DB.FILE.MAX.WARN}'
      name: 'Oracle: Too many database files'
      event_name: 'Oracle: Too many database files (over {$ORACLE.DB.FILE.MAX.WARN}% for 5 min)'
      priority: WARNING
      description: 'The number of datafiles is higher than `{$ORACLE.DB.FILE.MAX.WARN}`% of the available datafile limit.'
      tags:
        - tag: scope
          value: capacity
    - uuid: 362882973d0b45d1a09a687353734032
      expression: 'min(/Oracle by Zabbix agent 2/oracle.datafiles.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"],5m) * 100 / last(/Oracle by Zabbix agent 2/oracle.db_files_limit) > {$ORACLE.DB.FILE.MAX.WARN}'
      name: 'Oracle: Too many database files'
      event_name: 'Oracle: Too many database files (over {$ORACLE.DB.FILE.MAX.WARN}% for 5 min)'
      priority: WARNING
      description: 'The number of datafiles is higher than `{$ORACLE.DB.FILE.MAX.WARN}`% of the available datafile limit.'
      tags:
        - tag: scope
          value: capacity
    - uuid: 476001f0f52a45f59942d73c643371c1
      expression: 'min(/Oracle by ODBC/oracle.total_pga_used,5m) * 100 / last(/Oracle by ODBC/oracle.pga_target) > {$ORACLE.PGA.USE.MAX.WARN}'
      name: 'Oracle: Total PGA inuse is too high'
      event_name: 'Oracle: Total PGA inuse is too high (over {$ORACLE.PGA.USE.MAX.WARN}% for 5 min)'
      priority: WARNING
      description: 'The total PGA currently consumed by work areas is more than `{$ORACLE.PGA.USE.MAX.WARN}`% of `PGA_AGGREGATE_TARGET`.'
      tags:
        - tag: scope
          value: capacity
    - uuid: aecb78fc9a7549f2b8e68325530bcd99
      expression: 'min(/Oracle by Zabbix agent 2/oracle.total_pga_used,5m) * 100 / last(/Oracle by Zabbix agent 2/oracle.pga_target) > {$ORACLE.PGA.USE.MAX.WARN}'
      name: 'Oracle: Total PGA inuse is too high'
      event_name: 'Oracle: Total PGA inuse is too high (over {$ORACLE.PGA.USE.MAX.WARN}% for 5 min)'
      priority: WARNING
      description: 'The total PGA in use is more than `{$ORACLE.PGA.USE.MAX.WARN}`% of `PGA_AGGREGATE_TARGET`.'
      tags:
        - tag: scope
          value: capacity
  graphs:
    - uuid: d2db0e08beb6445a8b5dd9fb46249265
      name: 'MSSQL: Access methods'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.forwarded_records_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.full_scans_sec.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by ODBC'
            key: mssql.index_searches_sec.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.page_splits_sec.rate
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'MSSQL by ODBC'
            key: mssql.workfiles_created_sec.rate
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'MSSQL by ODBC'
            key: mssql.worktables_created_sec.rate
    - uuid: 7d06995b2daf4496a3f4856e5c562e59
      name: 'MSSQL: Access methods'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.forwarded_records_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.full_scans_sec.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.index_searches_sec.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.page_splits_sec.rate
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.workfiles_created_sec.rate
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.worktables_created_sec.rate
    - uuid: f22186d86d9346fe9e1f3292e1f0017c
      name: 'MSSQL: Auto-params'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.autoparam_attempts_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.failed_autoparams_sec.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by ODBC'
            key: mssql.safe_autoparams_sec.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.unsafe_autoparams_sec.rate
    - uuid: c1df070c49994a9fb3b15a3f9f15cf59
      name: 'MSSQL: Auto-params'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.autoparam_attempts_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.failed_autoparams_sec.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.safe_autoparams_sec.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.unsafe_autoparams_sec.rate
    - uuid: 24ef7368fb364616892c4928ba6167c6
      name: 'MSSQL: Cache objects'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.cache_object_counts
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.cache_objects_in_use
    - uuid: 15b49ae51375483182c927a06c7e094a
      name: 'MSSQL: Cache objects'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.cache_object_counts
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.cache_objects_in_use
    - uuid: 1f713999d38745b6bb2828e397a32970
      name: 'MSSQL: Compilations'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.sql_compilations_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.sql_recompilations_sec.rate
    - uuid: b3422c184eb7476e97e5b0f09bb70160
      name: 'MSSQL: Compilations'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.sql_compilations_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.sql_recompilations_sec.rate
    - uuid: 91af398cfb86472ba4a69e3df0816be7
      name: 'MSSQL: Database pages'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.database_pages
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.target_pages
    - uuid: ecc056aa9b4d4da3b41f6ad7ec8d600c
      name: 'MSSQL: Database pages'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.database_pages
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.target_pages
    - uuid: 0c9aaf223d6f4ba9bd17b0289af4bbe2
      name: 'MSSQL: Errors'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.errors_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.offline_errors_sec.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by ODBC'
            key: mssql.info_errors_sec.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.kill_connection_errors_sec.rate
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'MSSQL by ODBC'
            key: mssql.user_errors_sec.rate
    - uuid: b1decdef518c43c3bc8813b028e04025
      name: 'MSSQL: Errors'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.errors_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.offline_errors_sec.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.info_errors_sec.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.kill_connection_errors_sec.rate
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.user_errors_sec.rate
    - uuid: e35985317393409b9a764adcb05f07d0
      name: 'MSSQL: Locks'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.lock_requests_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.lock_timeouts_sec.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by ODBC'
            key: mssql.number_deadlocks_sec.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.lock_waits_sec.rate
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'MSSQL by ODBC'
            key: mssql.average_wait_time
    - uuid: 6dff1806a75343a6a81a94c5fee6a632
      name: 'MSSQL: Locks'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.lock_requests_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.lock_timeouts_sec.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.number_deadlocks_sec.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.lock_waits_sec.rate
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.average_wait_time
    - uuid: 8796ad9cc04f48cdbe8ef2cb5f429997
      name: 'MSSQL: Logins per second and Logouts per second'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.logins_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.logouts_sec.rate
    - uuid: ef6f803fbb744e8faa04673b5e3f5b38
      name: 'MSSQL: Logins per second and Logouts per second'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.logins_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.logouts_sec.rate
    - uuid: bc588f8933d846a19accdb66eb29ccb9
      name: 'MSSQL: Memory/cache load'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.cache_hit_ratio
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.buffer_cache_hit_ratio
    - uuid: b68986ff810f4336ad907d550f973b56
      name: 'MSSQL: Memory/cache load'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.cache_hit_ratio
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.buffer_cache_hit_ratio
    - uuid: 3d431f6cc6d34ef5820f2a24f3872b41
      name: 'MSSQL: Memory grants outstanding and pending'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.memory_grants_outstanding
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.memory_grants_pending
    - uuid: 335d81ea81384d1e85de7527598ce3f6
      name: 'MSSQL: Memory grants outstanding and pending'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.memory_grants_outstanding
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.memory_grants_pending
    - uuid: 0f0bc58e0c18421591d265f81c000021
      name: 'MSSQL: Page life expectancy'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.page_life_expectancy
    - uuid: 157c122b6d474441b4f95b91beee5730
      name: 'MSSQL: Page life expectancy'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.page_life_expectancy
    - uuid: 2b1d0e42f61a4312998775d21f7cabb7
      name: 'MSSQL: Pages'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.page_lookups_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.page_reads_sec.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by ODBC'
            key: mssql.page_writes_sec.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.readahead_pages_sec.rate
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'MSSQL by ODBC'
            key: mssql.checkpoint_pages_sec.rate
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'MSSQL by ODBC'
            key: mssql.free_list_stalls_sec.rate
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.lazy_writes_sec.rate
    - uuid: fff870597f4649d2a72941fb972d201c
      name: 'MSSQL: Pages'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.page_lookups_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.page_reads_sec.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.page_writes_sec.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.readahead_pages_sec.rate
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.checkpoint_pages_sec.rate
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.free_list_stalls_sec.rate
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.lazy_writes_sec.rate
    - uuid: 2e9273b0472c4a3e9049bea3548301d5
      name: 'MSSQL: Processes blocked'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.processes_blocked
    - uuid: 3297eadad79f4f7d8597f0eccb0af926
      name: 'MSSQL: Processes blocked'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.processes_blocked
    - uuid: f124ce3778bd4722bf0d2d598ac31b0f
      name: 'MSSQL: Server memory'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.target_server_memory
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.total_server_memory
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by ODBC'
            key: mssql.granted_workspace_memory
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.maximum_workspace_memory
    - uuid: 418dc893929c4f62beb361dcaaa6c56a
      name: 'MSSQL: Server memory'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.target_server_memory
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.total_server_memory
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.granted_workspace_memory
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.maximum_workspace_memory
    - uuid: 59ffd52c5c334d20870fc209c6c61398
      name: 'MSSQL: Transactions'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.transactions_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.batch_requests_sec.rate
    - uuid: 31467ce0afe24b2fa1a547f28eebc24a
      name: 'MSSQL: Transactions'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.transactions_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.batch_requests_sec.rate
    - uuid: 6979c0bcba0e4ac08c6bfefa0c648d40
      name: 'MSSQL: Waits per second'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.latch_waits_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.lock_waits_sec.rate
    - uuid: e35b61f7a547477cba31c9949be61f5e
      name: 'MSSQL: Waits per second'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.latch_waits_sec.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.lock_waits_sec.rate
    - uuid: 41cc736d93ce45d6aeb6dede77c97f08
      name: 'MSSQL: Wait times'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.average_latch_wait_time
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by ODBC'
            key: mssql.total_latch_wait_time
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by ODBC'
            key: mssql.average_wait_time
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by ODBC'
            key: mssql.lock_wait_time
    - uuid: ae485dce95974187a046b9743f32f629
      name: 'MSSQL: Wait times'
      graph_items:
        - color: 199C0D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.average_latch_wait_time
        - sortorder: '1'
          color: F63100
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.total_latch_wait_time
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.average_wait_time
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MSSQL by Zabbix agent 2'
            key: mssql.lock_wait_time
    - uuid: 3522a11cae374d08a751f419e51748e1
      name: 'MySQL: Bandwidth'
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          item:
            host: 'MySQL by ODBC'
            key: mysql.bytes_received.rate
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'MySQL by ODBC'
            key: mysql.bytes_sent.rate
    - uuid: 6ebb6f300b4a4ada80908ce11cae9e95
      name: 'MySQL: Bandwidth'
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.bytes_received.rate
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.bytes_sent.rate
    - uuid: b744bfe679fc48afbad8fe219fe88bb5
      name: 'MySQL: Bandwidth'
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.bytes_received.rate
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.bytes_sent.rate
    - uuid: 723784c0caba4856a7bb1e934c3ac54a
      name: 'MySQL: Bandwidth'
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.bytes_received.rate
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.bytes_sent.rate
    - uuid: 46d0f938ec754758a116c68b53d51cb7
      name: 'MySQL: Bandwidth'
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.bytes_received.rate
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.bytes_sent.rate
    - uuid: 51a6827371434314b76eaed17db0e09e
      name: 'MySQL: Connections'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by ODBC'
            key: mysql.aborted_clients.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by ODBC'
            key: mysql.aborted_connects.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by ODBC'
            key: mysql.connections.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by ODBC'
            key: mysql.max_used_connections
    - uuid: ea03bd4cc0f948f38ea638fe93f2ac69
      name: 'MySQL: Connections'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.aborted_clients.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.aborted_connects.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.connections.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.max_used_connections
    - uuid: 5fea4f7834644e0a80562c92b61c68d2
      name: 'MySQL: Connections'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.aborted_clients.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.aborted_connects.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.connections.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.max_used_connections
    - uuid: 689482bd6602443f8b9dcdb16598a68e
      name: 'MySQL: Connections'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.aborted_clients.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.aborted_connects.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.connections.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.max_used_connections
    - uuid: 0273aa8a2b5c4672a27fcf735ccfc1de
      name: 'MySQL: Connections'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.aborted_clients.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.aborted_connects.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.connections.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.max_used_connections
    - uuid: 07edad9e34394a689dc294c8ec27a37e
      name: 'MySQL: InnoDB buffer pool'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by ODBC'
            key: mysql.innodb_buffer_pool_pages_free
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by ODBC'
            key: mysql.innodb_buffer_pool_pages_total
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by ODBC'
            key: mysql.innodb_buffer_pool_read_requests.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by ODBC'
            key: mysql.innodb_buffer_pool_reads.rate
    - uuid: ee3890503acf44c58fcfedf3c5008656
      name: 'MySQL: InnoDB buffer pool'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.innodb_buffer_pool_pages_free
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.innodb_buffer_pool_pages_total
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.innodb_buffer_pool_read_requests.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.innodb_buffer_pool_reads.rate
    - uuid: d54d16a2b4d54bbd9a2a6669631ef96d
      name: 'MySQL: InnoDB buffer pool'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.innodb_buffer_pool_pages_free
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.innodb_buffer_pool_pages_total
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.innodb_buffer_pool_read_requests.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.innodb_buffer_pool_reads.rate
    - uuid: cdfec90ec0894187a52050f3fc738be7
      name: 'MySQL: InnoDB buffer pool'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.innodb_buffer_pool_pages_free
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.innodb_buffer_pool_pages_total
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.innodb_buffer_pool_read_requests.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.innodb_buffer_pool_reads.rate
    - uuid: 1614ceed2cb74addb9eb35330dea7ad2
      name: 'MySQL: InnoDB buffer pool'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.innodb_buffer_pool_pages_free
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.innodb_buffer_pool_pages_total
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.innodb_buffer_pool_read_requests.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.innodb_buffer_pool_reads.rate
    - uuid: 93bb7077e60047e59ac3fd308044722a
      name: 'MySQL: Operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by ODBC'
            key: mysql.com_delete.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by ODBC'
            key: mysql.com_insert.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by ODBC'
            key: mysql.com_select.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by ODBC'
            key: mysql.com_update.rate
    - uuid: a6296310a0cf4ffcad7b119c5089ef1f
      name: 'MySQL: Operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.com_delete.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.com_insert.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.com_select.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.com_update.rate
    - uuid: 2e962ad1647d4ccfb6db420a4c196d23
      name: 'MySQL: Operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.com_delete.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.com_insert.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.com_select.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.com_update.rate
    - uuid: 494552acd11044ef8fbea28d81c02e7d
      name: 'MySQL: Operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.com_delete.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.com_insert.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.com_select.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.com_update.rate
    - uuid: 43dcf7e893754c1ab12b3cf90c890f13
      name: 'MySQL: Operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.com_delete.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.com_insert.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.com_select.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.com_update.rate
    - uuid: 172ad44d7cef4c20b08b4babf8969805
      name: 'MySQL: Queries'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by ODBC'
            key: mysql.queries.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by ODBC'
            key: mysql.questions.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by ODBC'
            key: mysql.slow_queries.rate
    - uuid: ce723556c4974152a8eda029dbdad1bc
      name: 'MySQL: Queries'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.queries.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.questions.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.slow_queries.rate
    - uuid: 04e6ec47b0de4476b5c7a65ae012ca23
      name: 'MySQL: Queries'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.queries.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.questions.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.slow_queries.rate
    - uuid: ec0107cf2ef4499ca6522a66bc915dbd
      name: 'MySQL: Queries'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.queries.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.questions.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.slow_queries.rate
    - uuid: e1553784c34149a0bbe1e4ab2abc5a26
      name: 'MySQL: Queries'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.queries.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.questions.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.slow_queries.rate
    - uuid: 1ce62612e1174b3fa91bde29ccaa27ef
      name: 'MySQL: Threads'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by ODBC'
            key: mysql.threads_cached
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by ODBC'
            key: mysql.threads_connected
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by ODBC'
            key: mysql.threads_created.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by ODBC'
            key: mysql.threads_running
    - uuid: e7653013a2d94596a89c93f5352220df
      name: 'MySQL: Threads'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.threads_cached
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.threads_connected
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.threads_created.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent'
            key: mysql.threads_running
    - uuid: 974ac20701394b60823abbb84420d166
      name: 'MySQL: Threads'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.threads_cached
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.threads_connected
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.threads_created.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent 2'
            key: mysql.threads_running
    - uuid: 3e3616b5661546c98d20e9b1ef32c214
      name: 'MySQL: Threads'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.threads_cached
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.threads_connected
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.threads_created.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent 2 active'
            key: mysql.threads_running
    - uuid: 7547747e0c744353b98fcc914870035c
      name: 'MySQL: Threads'
      graph_items:
        - color: 199C0D
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.threads_cached
        - sortorder: '1'
          color: F63100
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.threads_connected
        - sortorder: '2'
          color: 00611C
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.threads_created.rate
        - sortorder: '3'
          color: F7941D
          item:
            host: 'MySQL by Zabbix agent active'
            key: mysql.threads_running
    - uuid: cf491b94c7674160ba36e2105026c834
      name: 'Oracle: Cache Hit Ratios'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by ODBC'
            key: oracle.buffer_cache_hit_ratio
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by ODBC'
            key: oracle.library_cache_hit_ratio
    - uuid: 41d6905fa6654468b7e872973265c5b6
      name: 'Oracle: Cache Hit Ratios'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.buffer_cache_hit_ratio
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.library_cache_hit_ratio
    - uuid: 72ad9e81bb5147e6827499143d256068
      name: 'Oracle: Datafiles'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by ODBC'
            key: oracle.db_files_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by ODBC'
            key: oracle.db_files_limit
    - uuid: 292f08d249d344db882a3447cc268ca6
      name: 'Oracle: Datafiles'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by Zabbix agent 2'
            key: 'oracle.datafiles.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.db_files_limit
    - uuid: dba3f3b856114d50b826a15cacd1d896
      name: 'Oracle: PGA'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by ODBC'
            key: oracle.total_pga_used
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by ODBC'
            key: oracle.pga_target
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle by ODBC'
            key: oracle.total_pga_allocated
    - uuid: 4b4d2430750c4885b4764c3b602dc091
      name: 'Oracle: PGA'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.total_pga_used
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.pga_target
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.total_pga_allocated
    - uuid: 3d1c6ffe69f34695b30d132d99d41dbb
      name: 'Oracle: Physical Read\Write Rate'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by ODBC'
            key: oracle.physical_writes_rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by ODBC'
            key: oracle.physical_reads_rate
    - uuid: 4e02f667b98042f6ac538692a074a982
      name: 'Oracle: Physical Read\Write Rate'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.physical_writes_rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.physical_reads_rate
    - uuid: 5002e9a128524991b16dbea89e0f4b07
      name: 'Oracle: Physical Read\Write Rate, Bytes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by ODBC'
            key: oracle.physical_write_bytes_rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by ODBC'
            key: oracle.physical_read_bytes_rate
    - uuid: 2bfd6cda93da4201a73c3d16caea8284
      name: 'Oracle: Physical Read\Write Rate, Bytes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.physical_write_bytes_rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.physical_read_bytes_rate
    - uuid: 044e0b3a485547b7b41939a78be80784
      name: 'Oracle: Processes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by ODBC'
            key: oracle.processes_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by ODBC'
            key: oracle.processes_limit
    - uuid: e51ad4ba7cca491faf7564a8d26bc1da
      name: 'Oracle: Processes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by Zabbix agent 2'
            key: 'oracle.proc.stats["{$ORACLE.CONNSTRING}","{$ORACLE.USER}","{$ORACLE.PASSWORD}","{$ORACLE.SERVICE}"]'
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.processes_limit
    - uuid: eef29b959d334e4b9ba3a4d83a571f1f
      name: 'Oracle: Sessions'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by ODBC'
            key: oracle.session_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by ODBC'
            key: oracle.session_active_background
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle by ODBC'
            key: oracle.session_inactive_user
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Oracle by ODBC'
            key: oracle.session_active_user
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Oracle by ODBC'
            key: oracle.session_limit
    - uuid: 3323be96dd454a92ade913ab6c2b589c
      name: 'Oracle: Sessions'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.session_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.session_active_background
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.session_inactive_user
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.session_active_user
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.session_limit
    - uuid: dd6a3c604ba446e793526564527c5c2f
      name: 'Oracle: SGA Memory Usage'
      type: STACKED
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by ODBC'
            key: oracle.sga_java_pool
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by ODBC'
            key: oracle.sga_large_pool
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle by ODBC'
            key: oracle.sga_shared_pool
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Oracle by ODBC'
            key: oracle.sga_log_buffer
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Oracle by ODBC'
            key: oracle.sga_fixed
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'Oracle by ODBC'
            key: oracle.sga_buffer_cache
    - uuid: ad7c9a7b4c7a4b4885cb1e91e7e79d3d
      name: 'Oracle: SGA Memory Usage'
      type: STACKED
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.sga_java_pool
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.sga_large_pool
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.sga_shared_pool
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.sga_log_buffer
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.sga_fixed
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.sga_buffer_cache
    - uuid: 48e400ae300642d2ac1b3f3e9d47acc0
      name: 'Oracle: Sort Operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by ODBC'
            key: oracle.memory_sorts_ratio
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by ODBC'
            key: oracle.disk_sorts
    - uuid: 3bbd3756a40d40f4b80851eb288d7822
      name: 'Oracle: Sort Operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.memory_sorts_ratio
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle by Zabbix agent 2'
            key: oracle.disk_sorts
    - uuid: 6b4b92c62cb94e10b11f218ed35f6211
      name: 'PostgreSQL bgwriter'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.bgwriter.buffers_alloc.rate
        - sortorder: '1'
          color: F63100
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.bgwriter.buffers_clean.rate
        - sortorder: '2'
          color: 00611C
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.bgwriter.buffers_backend.rate
        - sortorder: '3'
          color: F7941D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.bgwriter.buffers_checkpoint.rate
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.bgwriter.maxwritten_clean.rate
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.bgwriter.buffers_backend_fsync.rate
    - uuid: 0f8ec9f5313348bfbe3b11836f6011d6
      name: 'PostgreSQL bgwriter'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.bgwriter.buffers_alloc.rate
        - sortorder: '1'
          color: F63100
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.bgwriter.buffers_clean.rate
        - sortorder: '2'
          color: 00611C
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.bgwriter.buffers_backend.rate
        - sortorder: '3'
          color: F7941D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.bgwriter.buffers_checkpoint.rate
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.bgwriter.maxwritten_clean.rate
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.bgwriter.buffers_backend_fsync.rate
    - uuid: 4a105d193df64be7898ac19a2f07faa4
      name: 'PostgreSQL checkpoints'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.bgwriter.checkpoints_timed.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.bgwriter.checkpoints_req.rate
        - sortorder: '2'
          color: 00611C
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.bgwriter.checkpoint_sync_time.rate
        - sortorder: '3'
          color: F7941D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.bgwriter.checkpoint_write_time.rate
    - uuid: c15a7590e6594541acb6327852af11fa
      name: 'PostgreSQL checkpoints'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.bgwriter.checkpoints_timed.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.bgwriter.checkpoints_req.rate
        - sortorder: '2'
          color: 00611C
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.bgwriter.checkpoint_sync_time.rate
        - sortorder: '3'
          color: F7941D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.bgwriter.checkpoint_write_time.rate
    - uuid: 8d41d719832049a5a1fcd6f4da67fb6a
      name: 'PostgreSQL connections'
      ymin_type_1: FIXED
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.connections.sum.total
        - sortorder: '1'
          color: F63100
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.connections.sum.total_pct
        - sortorder: '2'
          color: 00611C
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.connections.sum.active
        - sortorder: '3'
          color: F7941D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.connections.sum.idle
        - sortorder: '4'
          color: FC6EA3
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.connections.sum.idle_in_transaction
        - sortorder: '5'
          color: 6C59DC
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.connections.sum.prepared
        - sortorder: '6'
          color: C7A72D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.connections.sum.waiting
    - uuid: 6748cbe523f44028bc84899cf3c68881
      name: 'PostgreSQL connections'
      ymin_type_1: FIXED
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.connections.sum.total
        - sortorder: '1'
          color: F63100
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.connections.sum.total_pct
        - sortorder: '2'
          color: 00611C
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.connections.sum.active
        - sortorder: '3'
          color: F7941D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.connections.sum.idle
        - sortorder: '4'
          color: FC6EA3
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.connections.sum.idle_in_transaction
        - sortorder: '5'
          color: 6C59DC
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.connections.sum.prepared
        - sortorder: '6'
          color: C7A72D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.connections.sum.waiting
    - uuid: 1e9a55ee61824779a9f46f42ec21abef
      name: 'PostgreSQL ping'
      ymin_type_1: FIXED
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: 'pgsql.ping["{$PG.HOST}","{$PG.PORT}"]'
        - sortorder: '1'
          color: F63100
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: 'pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
    - uuid: 5705f8c49a6343b39e4a1a574f14b16d
      name: 'PostgreSQL ping'
      ymin_type_1: FIXED
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: 'pgsql.ping["{$PG.HOST}","{$PG.PORT}"]'
        - sortorder: '1'
          color: F63100
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: 'pgsql.ping.time["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
    - uuid: d8cf31fc39584a63b9384d9c3ebf40ee
      name: 'PostgreSQL replication lag'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: 'pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
    - uuid: 8687fc6723b8477ba4c909b4d348303c
      name: 'PostgreSQL replication lag'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: 'pgsql.replication.lag.sec["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
    - uuid: 10d1de74e9d848399ca038055e5cc8ce
      name: 'PostgreSQL transactions'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.transactions.active
        - sortorder: '1'
          color: F63100
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.transactions.idle
        - sortorder: '2'
          color: 00611C
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.transactions.prepared
        - sortorder: '3'
          color: F7941D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.transactions.waiting
    - uuid: 245d91951a8048d1ad091cdcacb5bbeb
      name: 'PostgreSQL transactions'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.transactions.active
        - sortorder: '1'
          color: F63100
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.transactions.idle
        - sortorder: '2'
          color: 00611C
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.transactions.prepared
        - sortorder: '3'
          color: F7941D
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.transactions.waiting
    - uuid: 45fe7967596741129b4f2462922636bf
      name: 'PostgreSQL uptime'
      show_triggers: 'NO'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: 'pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
        - sortorder: '1'
          color: F63100
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: 'pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
    - uuid: dc9cd08e1f6a4e3594eef539b3d00df9
      name: 'PostgreSQL uptime'
      show_triggers: 'NO'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: 'pgsql.uptime["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
        - sortorder: '1'
          color: F63100
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: 'pgsql.cache.hit["{$PG.HOST}","{$PG.PORT}","{$PG.USER}","{$PG.PASSWORD}","{$PG.DATABASE}"]'
    - uuid: 93ca2dc7a3ff4a458c45e2a56390ce72
      name: 'PostgreSQL WAL'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.wal.write
        - sortorder: '1'
          color: F63100
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent'
            key: pgsql.wal.count
    - uuid: 1fd6ffdc171146d6b05d9891ab56312c
      name: 'PostgreSQL WAL'
      ymin_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.wal.write
        - sortorder: '1'
          color: F63100
          yaxisside: RIGHT
          item:
            host: 'PostgreSQL by Zabbix agent active'
            key: pgsql.wal.count
