zabbix_export:
  version: '6.0'
  date: '2023-10-29T21:25:35Z'
  groups:
    - uuid: 22941f4e01294888a9bed3aae15f6ef9
      name: Templates/AWNET
  templates:
    - uuid: b7daeb1192904504a5eedbddf33be7d1
      template: PgBouncer
      name: PgBouncer
      description: |
        На основе: https://github.com/Lelik13a/Zabbix-PgBouncer
        Расположение: https://devel.a0fs.ru/ncc.zabbix_templates/file/tip/pgBouncer
      groups:
        - name: Templates/AWNET
      items:
        - uuid: 43308caa0203485ba54520d1277e3848
          name: 'Общее количество свободных клиентских подключений'
          type: DEPENDENT
          key: pgbouncer.lists.free_clients
          delay: '0'
          history: 30d
          trends: 90d
          preprocessing:
            - type: REGEX
              parameters:
                - 'free_clients\s+\|(.*)'
                - \1
          master_item:
            key: pgbouncer.pool.lists
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: 4c8072b421d14f589e18c9c33cef3ca6
          name: 'Общее количество свободных серверных подключений'
          type: DEPENDENT
          key: pgbouncer.lists.free_servers
          delay: '0'
          history: 30d
          trends: 90d
          preprocessing:
            - type: REGEX
              parameters:
                - 'free_servers\s+\|(.*)'
                - \1
          master_item:
            key: pgbouncer.pool.lists
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: d09efd07dff342478e47a77b0cad696e
          name: 'Общее количество соединений в состоянии авторизации'
          type: DEPENDENT
          key: pgbouncer.lists.login_clients
          delay: '0'
          history: 30d
          trends: 90d
          preprocessing:
            - type: REGEX
              parameters:
                - 'login_clients\s+\|(.*)'
                - \1
          master_item:
            key: pgbouncer.pool.lists
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: 8af7e91ff25a4b3f81482affe6c876ab
          name: 'Количество пулов подключений'
          type: DEPENDENT
          key: pgbouncer.lists.pools
          delay: '0'
          history: 30d
          trends: 90d
          description: 'Count of pools.'
          preprocessing:
            - type: REGEX
              parameters:
                - 'pools\s+\|(.*)'
                - \1
          master_item:
            key: pgbouncer.pool.lists
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: 4919263e31d14542aeae03e9dc54cbb2
          name: 'Общее количество подключённых клиентов'
          type: DEPENDENT
          key: pgbouncer.lists.used_clients
          delay: '0'
          history: 30d
          trends: 90d
          preprocessing:
            - type: REGEX
              parameters:
                - 'used_clients\s+\|(.*)'
                - \1
          master_item:
            key: pgbouncer.pool.lists
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: bf97b099778a485f857d1ea590315885
          name: 'Общее количество задействованных подключений к серверу'
          type: DEPENDENT
          key: pgbouncer.lists.used_servers
          delay: '0'
          history: 30d
          trends: 90d
          description: 'Count of used servers.'
          preprocessing:
            - type: REGEX
              parameters:
                - 'used_servers\s+\|(.*)'
                - \1
          master_item:
            key: pgbouncer.pool.lists
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: 70e000f4bf0a4d6e9e5addc99e3b4b3a
          name: 'Количество пользователй'
          type: DEPENDENT
          key: pgbouncer.lists.users
          delay: '0'
          history: 30d
          trends: 90d
          preprocessing:
            - type: REGEX
              parameters:
                - 'users\s+\|(.*)'
                - \1
          master_item:
            key: pgbouncer.pool.lists
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: 2f7e4233cec54abfb2f54b252a89863f
          name: 'PgBouncer lists raw'
          key: pgbouncer.pool.lists
          history: '0'
          trends: '0'
          value_type: TEXT
          tags:
            - tag: Application
              value: PgBouncer
        - uuid: 82bfee5ff67e4830bab212d0052e9725
          name: 'PgBouncer pools raw'
          key: pgbouncer.pool.pools
          history: '0'
          trends: '0'
          value_type: TEXT
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var res = []
                  var list_buf = value.split('\n');
                  var my_trim = function (my_el)  {
                     if (my_el != undefined) {
                        return String(my_el).trim()
                     } else {
                        return '';
                     };
                  };
                  
                  for (var le in list_buf) {
                      if (list_buf[le].trim().length == 0) continue;
                      var el_buf = list_buf[le].split('|');
                  
                      res.push({
                          database: my_trim(el_buf[0]),
                          user: my_trim(el_buf[1]),
                          cl_active: my_trim(el_buf[2]),
                          cl_waiting: my_trim(el_buf[3]),
                          cl_active_cancel_req: my_trim(el_buf[4]),
                          cl_waiting_cancel_req: my_trim(el_buf[5]),
                          sv_active: my_trim(el_buf[6]),
                          sv_active_cancel: my_trim(el_buf[7]),
                          sv_being_canceled: my_trim(el_buf[8]),
                          sv_idle: my_trim(el_buf[9]),
                          sv_used: my_trim(el_buf[10]),
                          sv_tested: my_trim(el_buf[11]),
                          sv_login: my_trim(el_buf[12]),
                          maxwait: my_trim(el_buf[13]),
                          maxwait_us: my_trim(el_buf[14]),
                          pool_mode: my_trim(el_buf[15]),
                      });
                  }
                  
                  return JSON.stringify(res);
          tags:
            - tag: Application
              value: PgBouncer
        - uuid: 5d232829001b4711b9441668e430c0ae
          name: 'PgBouncer stats raw'
          key: pgbouncer.pool.stats
          history: '0'
          trends: '0'
          value_type: TEXT
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |2
                      var res = []
                      var list_buf = value.split('\n');
                      var my_trim = function (my_el)  {
                         if (my_el != undefined) {
                            return String(my_el).trim()
                         } else {
                            return '';
                         };
                      };
                      
                      for (var le in list_buf) {
                          if (list_buf[le].trim().length == 0) continue;
                          var el_buf = list_buf[le].split('|');
                  
                          res.push({
                              name: my_trim(el_buf[0]),
                              total_xact_count: my_trim(el_buf[1]),
                              total_query_count: my_trim(el_buf[2]),
                              total_received: my_trim(el_buf[3]),
                              total_sent: my_trim(el_buf[4]),
                              total_xact_time: my_trim(el_buf[5]),
                              total_query_time: my_trim(el_buf[6]),
                              total_wait_time: my_trim(el_buf[7]),
                              avg_xact_count: my_trim(el_buf[8]),
                              avg_query_count: my_trim(el_buf[9]),
                              avg_recv: my_trim(el_buf[10]),
                              avg_sent: my_trim(el_buf[11]),
                              avg_xact_time: my_trim(el_buf[12]),
                              avg_query_time: my_trim(el_buf[13]),
                              avg_wait_time: my_trim(el_buf[14]),
                          });
                      }
                  
                      return JSON.stringify(res);
          tags:
            - tag: Application
              value: PgBouncer
        - uuid: 6523b0c631b54900ad00e2b914bbc7ee
          name: 'PgBouncer totals raw'
          key: pgbouncer.pool.totals
          history: '0'
          trends: '0'
          value_type: TEXT
          tags:
            - tag: Application
              value: PgBouncer
        - uuid: c5d602b4909b40c3a3adf30969a4d854
          name: 'Среднее количество запросов по всем БД'
          type: DEPENDENT
          key: pgbouncer.total.avg_query_count
          delay: '0'
          history: 30d
          trends: 90d
          preprocessing:
            - type: REGEX
              parameters:
                - ' avg_query_count\s+\|(.*)'
                - \1
          master_item:
            key: pgbouncer.pool.totals
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: e0bd310bb159467ab227b01435267dd5
          name: 'Среднее время запроса по всем БД'
          type: DEPENDENT
          key: pgbouncer.total.avg_query_time
          delay: '0'
          history: 30d
          trends: 90d
          value_type: FLOAT
          units: ms
          preprocessing:
            - type: REGEX
              parameters:
                - ' avg_query_time\s+\|(.*)'
                - \1
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: pgbouncer.pool.totals
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: 69d5830cbb8d49a9a29f8cedd786ca6c
          name: 'Общее среднее время ожидания клиентом сервера (среднее в секунду)'
          type: DEPENDENT
          key: pgbouncer.total.avg_wait_time
          delay: '0'
          history: 30d
          trends: 90d
          value_type: FLOAT
          units: ms
          preprocessing:
            - type: REGEX
              parameters:
                - ' avg_wait_time\s+\|(.*)'
                - \1
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: pgbouncer.pool.totals
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: 7370e257bd5340f1bab9c3b45720e465
          name: 'Среднее количество транзакций по всем БД'
          type: DEPENDENT
          key: pgbouncer.total.avg_xact_count
          delay: '0'
          history: 30d
          trends: 90d
          preprocessing:
            - type: REGEX
              parameters:
                - ' avg_xact_count\s+\|(.*)'
                - \1
          master_item:
            key: pgbouncer.pool.totals
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: 20aa4eb901d044e69d10d45576f492c0
          name: 'Средняя продолжительность транзакции по всем БД'
          type: DEPENDENT
          key: pgbouncer.total.avg_xact_time
          delay: '0'
          history: 30d
          trends: 90d
          value_type: FLOAT
          units: ms
          preprocessing:
            - type: REGEX
              parameters:
                - ' avg_xact_time\s+\|(.*)'
                - \1
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: pgbouncer.pool.totals
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: ac4adb1e65934dab8b13c9bedd88441e
          name: 'Общее количество полученных от клиентов данных по всем БД'
          type: DEPENDENT
          key: pgbouncer.total.total_client_bytes
          delay: '0'
          history: 30d
          trends: 90d
          units: Bps
          preprocessing:
            - type: REGEX
              parameters:
                - ' total_client_bytes\s+\|(.*)'
                - \1
            - type: CHANGE_PER_SECOND
              parameters:
                - ''
          master_item:
            key: pgbouncer.pool.totals
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: c120596534a242889f589adddfb25048
          name: 'Общее количество запросов по всем БД'
          type: DEPENDENT
          key: pgbouncer.total.total_query_count
          delay: '0'
          history: 30d
          trends: 90d
          units: rps
          preprocessing:
            - type: REGEX
              parameters:
                - ' total_query_count\s+\|(.*)'
                - \1
            - type: CHANGE_PER_SECOND
              parameters:
                - ''
          master_item:
            key: pgbouncer.pool.totals
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: 73635a0c208547ddac86c5636429a1ce
          name: 'Обще количество информации отправленное клиентам по всем БД'
          type: DEPENDENT
          key: pgbouncer.total.total_server_bytes
          delay: '0'
          history: 30d
          trends: 90d
          units: Bps
          preprocessing:
            - type: REGEX
              parameters:
                - ' total_server_bytes\s+\|(.*)'
                - \1
            - type: CHANGE_PER_SECOND
              parameters:
                - ''
          master_item:
            key: pgbouncer.pool.totals
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
        - uuid: f68d255de9c64005ad3b569e10517178
          name: 'Общее количество транзакций по всем БД в секунду'
          type: DEPENDENT
          key: pgbouncer.total.total_xact_count
          delay: '0'
          history: 30d
          trends: 90d
          units: tps
          preprocessing:
            - type: REGEX
              parameters:
                - ' total_xact_count\s+\|(.*)'
                - \1
            - type: CHANGE_PER_SECOND
              parameters:
                - ''
          master_item:
            key: pgbouncer.pool.totals
          tags:
            - tag: Application
              value: PgBouncer
            - tag: Func
              value: 'Общая статистика'
      discovery_rules:
        - uuid: 415d14383e6a45c4ae876618c9b83adc
          name: 'PgBouncer pools discovery'
          key: pgbouncer.pool.discover
          delay: 30m
          lifetime: '0'
          item_prototypes:
            - uuid: cb931dfeada449bf9749d11b0fc506c7
              name: '{#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Активных подключений'
              type: DEPENDENT
              key: 'pgbouncer.pools.db.cl_active[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
              delay: '0'
              history: 30d
              trends: 90d
              description: 'Client connections that are linked to server connection and can process queries.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#PGBOUNCER_DATABASE}" && @.user == "{#PGBOUNCER_USER}")].cl_active'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.pools
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: DatabaseUser
                  value: '{#PGBOUNCER_USER}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: ffa5dd15a6194d3a89b0c4b9b01777dd
              name: '{#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Активных подключений в ожидании'
              type: DEPENDENT
              key: 'pgbouncer.pools.db.cl_waiting[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
              delay: '0'
              history: 30d
              trends: 90d
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#PGBOUNCER_DATABASE}" && @.user == "{#PGBOUNCER_USER}")].cl_waiting'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.pools
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: DatabaseUser
                  value: '{#PGBOUNCER_USER}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: d40aa8b10f52435e88ac0d7dcb509c38
              name: '{#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Максимальное ожидание'
              type: DEPENDENT
              key: 'pgbouncer.pools.db.maxwait[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
              delay: '0'
              history: 30d
              trends: 90d
              units: s
              description: 'Показывает как долго находится в очереди ожидания подключения к серверу самый старый запрос. Данный параметр начинает расти при не достаточной производительности сервера при обработке запросов. Если наблюдаем данную ситуацию стоит увеличить размер пула подключений к серверу (pool_size)'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#PGBOUNCER_DATABASE}" && @.user == "{#PGBOUNCER_USER}")].maxwait'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.pools
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: DatabaseUser
                  value: '{#PGBOUNCER_USER}'
                - tag: Func
                  value: 'Статистика БД'
              trigger_prototypes:
                - uuid: 46dd8a2b9a0e4346a1041b897775d44c
                  expression: 'last(/PgBouncer/pgbouncer.pools.db.maxwait[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}])>1'
                  name: '{#PGBOUNCER_USER}: Максимальное время ожидания клиентом в очереди превысило 1 секунду'
                  opdata: 'Время ожидания:  {ITEM.LASTVALUE1}'
                  priority: AVERAGE
            - uuid: 0bc401b00ab64e068068c02aa6843210
              name: '{#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Максимальное ожидание (микросекундная компонента)'
              type: DEPENDENT
              key: 'pgbouncer.pools.db.maxwait_us[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
              delay: '0'
              history: 30d
              trends: 90d
              value_type: FLOAT
              units: micros
              description: 'Смотреть в описание "Максимального ожидания"'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#PGBOUNCER_DATABASE}" && @.user == "{#PGBOUNCER_USER}")].maxwait_us'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.pools
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: DatabaseUser
                  value: '{#PGBOUNCER_USER}'
                - tag: Func
                  value: 'Статистика БД'
              trigger_prototypes:
                - uuid: a4971a735cc04479bbde632a0f03926f
                  expression: 'last(/PgBouncer/pgbouncer.pools.db.maxwait_us[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}])>100'
                  name: '{#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Максимальное время ожидания в очереди на подключение превысило 100 микросекунд'
                  opdata: 'Время ожидания:  {ITEM.LASTVALUE1}'
                  priority: INFO
            - uuid: 7d54c757ce8f4b6eb75b470431aa31f5
              name: '{#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Активных серверных подключений'
              type: DEPENDENT
              key: 'pgbouncer.pools.db.sv_active[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
              delay: '0'
              history: 30d
              trends: 90d
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#PGBOUNCER_DATABASE}" && @.user == "{#PGBOUNCER_USER}")].sv_active'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.pools
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: DatabaseUser
                  value: '{#PGBOUNCER_USER}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: 2a95424618784993986b283ed2b473bf
              name: '{#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Простаивающие подключения'
              type: DEPENDENT
              key: 'pgbouncer.pools.db.sv_idle[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
              delay: '0'
              history: 30d
              trends: 90d
              description: 'Server connections that are unused and immediately usable for client queries.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#PGBOUNCER_DATABASE}" && @.user == "{#PGBOUNCER_USER}")].sv_idle'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.pools
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: DatabaseUser
                  value: '{#PGBOUNCER_USER}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: bd06403ea5334b01833798324d22345b
              name: '{#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Активных серверных подключений на стадии авторизации'
              type: DEPENDENT
              key: 'pgbouncer.pools.db.sv_login[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
              delay: '0'
              history: 30d
              trends: 90d
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#PGBOUNCER_DATABASE}" && @.user == "{#PGBOUNCER_USER}")].sv_login'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.pools
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: DatabaseUser
                  value: '{#PGBOUNCER_USER}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: b7e79133dfca42f49aebb93d5d8749d3
              name: '{#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Подключения к серверу, находящиеся либо в стадии проверки либо сброса и возврата в пул свободных'
              type: DEPENDENT
              key: 'pgbouncer.pools.db.sv_tested[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
              delay: '0'
              history: 30d
              trends: 90d
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#PGBOUNCER_DATABASE}" && @.user == "{#PGBOUNCER_USER}")].sv_tested'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.pools
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: DatabaseUser
                  value: '{#PGBOUNCER_USER}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: 9326b8cd476e4d9891153a0c2924c4d7
              name: '{#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Задействованные подключения к серверу'
              type: DEPENDENT
              key: 'pgbouncer.pools.db.sv_used[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
              delay: '0'
              history: 30d
              trends: 90d
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#PGBOUNCER_DATABASE}" && @.user == "{#PGBOUNCER_USER}")].sv_used'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.pools
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: DatabaseUser
                  value: '{#PGBOUNCER_USER}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: 1475ff5de3c54ba792458e063bd92d29
              name: '{#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Режим управления пулом соединений'
              type: DEPENDENT
              key: 'pgbouncer.pools.pool_mode[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
              delay: '0'
              history: 30d
              trends: '0'
              value_type: CHAR
              description: 'The pooling mode in use'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#PGBOUNCER_DATABASE}" && @.user == "{#PGBOUNCER_USER}")].pool_mode'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.pools
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: DatabaseUser
                  value: '{#PGBOUNCER_USER}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: 7de8a33441434eedb9c49a5c6f9d12b8
              name: '{#PGBOUNCER_DATABASE}: Средняя продолжительность запроса'
              type: DEPENDENT
              key: 'pgbouncer.stats.db.avg_query_time[{#PGBOUNCER_DATABASE}]'
              delay: '0'
              history: 30d
              trends: 90d
              units: ms
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.name == "{#PGBOUNCER_DATABASE}")].avg_query_time'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.stats
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: 4911f76b7b03407b9b39737303714db6
              name: '{#PGBOUNCER_DATABASE}: Среднее время ожидания свободного подключения'
              type: DEPENDENT
              key: 'pgbouncer.stats.db.avg_wait_time[{#PGBOUNCER_DATABASE}]'
              delay: '0'
              history: 30d
              trends: 90d
              units: ms
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.name == "{#PGBOUNCER_DATABASE}")].avg_wait_time'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.stats
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: Func
                  value: 'Статистика БД'
              trigger_prototypes:
                - uuid: 8adff22128884a8cb0e30f215776ae00
                  expression: 'last(/PgBouncer/pgbouncer.stats.db.avg_wait_time[{#PGBOUNCER_DATABASE}])>{$PBBOUNCER.WAIT.TIME}'
                  name: '{#PGBOUNCER_DATABASE}: Среднее время ожидания в очереди более {$PBBOUNCER.WAIT.TIME}ms'
                  priority: AVERAGE
            - uuid: 70c41f4bed104f65b47256cb1ccd3ff9
              name: '{#PGBOUNCER_DATABASE}: Средняя продолжительность транзакции'
              type: DEPENDENT
              key: 'pgbouncer.stats.db.avg_xact_time[{#PGBOUNCER_DATABASE}]'
              delay: '0'
              history: 30d
              trends: 90d
              units: ms
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.name == "{#PGBOUNCER_DATABASE}")].avg_xact_time'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
              master_item:
                key: pgbouncer.pool.stats
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: c7784c3d75d0411d920fe6856cf050ea
              name: '{#PGBOUNCER_DATABASE}: Среднее количество запросов к БД в секунду'
              type: DEPENDENT
              key: 'pgbouncer.stats.db.total_query_count[{#PGBOUNCER_DATABASE}]'
              delay: '0'
              history: 30d
              trends: 90d
              units: rps
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.name == "{#PGBOUNCER_DATABASE}")].total_query_count'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
                - type: CHANGE_PER_SECOND
                  parameters:
                    - ''
              master_item:
                key: pgbouncer.pool.stats
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: d6eb4da92aeb44cea5aefb536b4efae1
              name: '{#PGBOUNCER_DATABASE}: Средняя скорость получения данных балансировщиком'
              type: DEPENDENT
              key: 'pgbouncer.stats.db.total_received[{#PGBOUNCER_DATABASE}]'
              delay: '0'
              history: 30d
              trends: 90d
              units: b/s
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.name == "{#PGBOUNCER_DATABASE}")].total_received'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
                - type: CHANGE_PER_SECOND
                  parameters:
                    - ''
              master_item:
                key: pgbouncer.pool.stats
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: 71b50f61435f4df4b97e464952cde5ab
              name: '{#PGBOUNCER_DATABASE}: Средняя скорость отправки данных балансировщиком'
              type: DEPENDENT
              key: 'pgbouncer.stats.db.total_sent[{#PGBOUNCER_DATABASE}]'
              delay: '0'
              history: 30d
              trends: 90d
              units: b/s
              description: 'Network traffic sent by pgbouncer in bytes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.name == "{#PGBOUNCER_DATABASE}")].total_sent'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
                - type: CHANGE_PER_SECOND
                  parameters:
                    - ''
              master_item:
                key: pgbouncer.pool.stats
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: Func
                  value: 'Статистика БД'
            - uuid: 1dad183897b14125b07ab89a01caa549
              name: '{#PGBOUNCER_DATABASE}: Среднее количество транзакций в секунду.'
              type: DEPENDENT
              key: 'pgbouncer.stats.db.total_xact_count[{#PGBOUNCER_DATABASE}]'
              delay: '0'
              history: 30d
              trends: 90d
              units: tps
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.name == "{#PGBOUNCER_DATABASE}")].total_xact_count'
                - type: JSONPATH
                  parameters:
                    - '$[0]'
                - type: CHANGE_PER_SECOND
                  parameters:
                    - ''
              master_item:
                key: pgbouncer.pool.stats
              tags:
                - tag: Application
                  value: PgBouncer
                - tag: DatabaseName
                  value: '{#PGBOUNCER_DATABASE}'
                - tag: Func
                  value: 'Статистика БД'
          graph_prototypes:
            - uuid: 25021355bd724712a4b00e6fc62bcaac
              name: 'PgBouncer: {#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Клиентские подключения'
              graph_items:
                - color: 199C0D
                  item:
                    host: PgBouncer
                    key: 'pgbouncer.pools.db.cl_active[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: PgBouncer
                    key: 'pgbouncer.pools.db.cl_waiting[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
            - uuid: ca60cfc7d1be4eb5a745e0ae402b7bc4
              name: 'PgBouncer: {#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Подключения к серверу'
              graph_items:
                - color: 199C0D
                  item:
                    host: PgBouncer
                    key: 'pgbouncer.pools.db.sv_active[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: PgBouncer
                    key: 'pgbouncer.pools.db.sv_login[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
                - sortorder: '2'
                  color: 2774A4
                  item:
                    host: PgBouncer
                    key: 'pgbouncer.pools.db.sv_tested[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: PgBouncer
                    key: 'pgbouncer.pools.db.sv_idle[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: PgBouncer
                    key: 'pgbouncer.pools.db.sv_used[{#PGBOUNCER_DATABASE},{#PGBOUNCER_USER}]'
            - uuid: 770b8bebd0074052848690582040f3d6
              name: 'PgBouncer: Сетевой трафик {#PGBOUNCER_DATABASE}'
              graph_items:
                - sortorder: '1'
                  drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: PgBouncer
                    key: 'pgbouncer.stats.db.total_received[{#PGBOUNCER_DATABASE}]'
                - sortorder: '2'
                  drawtype: GRADIENT_LINE
                  color: 0040FF
                  item:
                    host: PgBouncer
                    key: 'pgbouncer.stats.db.total_sent[{#PGBOUNCER_DATABASE}]'
      macros:
        - macro: '{$PBBOUNCER.WAIT.TIME}'
          value: '1000'
          description: 'Time spent by clients waiting for a server, in microseconds (average per second).'
      dashboards:
        - uuid: 391b2243c1c54c9cb4e1031f514d96b2
          name: 'PgBouncer - обзор'
          pages:
            - widgets:
                - type: GRAPH_CLASSIC
                  width: '12'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid
                      value:
                        host: PgBouncer
                        name: 'PgBouncer: Подключения'
                - type: GRAPH_PROTOTYPE
                  'y': '5'
                  width: '12'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid
                      value:
                        host: PgBouncer
                        name: 'PgBouncer: {#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Клиентские подключения'
                - type: GRAPH_CLASSIC
                  'y': '10'
                  width: '12'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid
                      value:
                        host: PgBouncer
                        key: pgbouncer.total.avg_query_count
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: GRAPH_CLASSIC
                  x: '12'
                  width: '12'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid
                      value:
                        host: PgBouncer
                        name: 'PgBouncer: Объём передаваемых данных по всем БД'
                - type: GRAPH_PROTOTYPE
                  x: '12'
                  'y': '5'
                  width: '12'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid
                      value:
                        host: PgBouncer
                        name: 'PgBouncer: {#PGBOUNCER_DATABASE}[{#PGBOUNCER_USER}]: Подключения к серверу'
                - type: GRAPH_CLASSIC
                  x: '12'
                  'y': '10'
                  width: '12'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid
                      value:
                        host: PgBouncer
                        key: pgbouncer.total.avg_query_time
                    - type: INTEGER
                      name: source_type
                      value: '1'
  graphs:
    - uuid: 8e8efd0772ab4053bb8c79173010d3e6
      name: 'PgBouncer: Объём передаваемых данных по всем БД'
      graph_items:
        - drawtype: FILLED_REGION
          color: 00FF00
          item:
            host: PgBouncer
            key: pgbouncer.total.total_client_bytes
        - sortorder: '1'
          drawtype: FILLED_REGION
          color: 0040FF
          item:
            host: PgBouncer
            key: pgbouncer.total.total_server_bytes
    - uuid: b433d80b3d69405e809b607e0a2587b0
      name: 'PgBouncer: Подключения'
      graph_items:
        - color: 199C0D
          item:
            host: PgBouncer
            key: pgbouncer.lists.free_clients
        - sortorder: '1'
          color: F63100
          item:
            host: PgBouncer
            key: pgbouncer.lists.free_servers
        - sortorder: '2'
          color: 2774A4
          item:
            host: PgBouncer
            key: pgbouncer.lists.login_clients
        - sortorder: '3'
          color: F7941D
          item:
            host: PgBouncer
            key: pgbouncer.lists.used_clients
        - sortorder: '4'
          color: FC6EA3
          item:
            host: PgBouncer
            key: pgbouncer.lists.used_servers
