zabbix_export:
  version: '8.0'
  host_groups:
    - uuid: f2481361f99448eea617b7b1d4765566
      name: 'Discovered hosts'
  hosts:
    - host: test
      name: test
      groups:
        - name: 'Discovered hosts'
      interfaces:
        - interface_ref: if1
      items:
        - name: trap
          type: TRAP
          key: trap
      discovery_rules:
        - name: TEST
          type: SCRIPT
          key: 1_level_nested_discovery
          delay: 1h
          params: |
            return JSON.stringify([
              {
                "database": "db1",
                "created_at": "2025-02-01T12:30:00Z",
                "encoding": "UTF8",
                "tablespaces": [
                  { "name": "ts1", "max_size": "10GB" }
                ]
              },
              {
                "database": "db2",
                "created_at": "2024-11-15T08:45:00Z",
                "encoding": "UTF16",
                "tablespaces": [
                  { "name": "ts1", "max_size": "5GB" },
                  { "name": "ts2", "max_size": "25GB" }
                ]
              }]
            )
          lifetime_type: DELETE_IMMEDIATELY
          item_prototypes:
            - name: 'Active connections to {#DB}'
              key: 'db.connections[{#DB}]'
              interface_ref: if1
          lld_macro_paths:
            - lld_macro: '{#DB}'
              path: $.database
        - name: 'Discover tablespaces for {#DB}'
          type: NESTED
          key: 'db.tablespace.discovery[{#DB}]'
          lifetime_type: DELETE_IMMEDIATELY
          item_prototypes:
            - name: 'Size of tablespace {#TSNAME} for {#DB}'
              key: 'db.ts.size[{#DB}, {#TSNAME}]'
              status: DISABLED
              description: '{#DB}'
              preprocessing:
                - type: TRIM
                  parameters:
                    - '12'
              interface_ref: if1
              trigger_prototypes:
                - expression: 'last(/test/db.ts.size[{#DB}, {#TSNAME}])>0'
                  recovery_mode: NONE
                  name: 'Size of tablespace {#TSNAME} for {#DB} is something'
                  priority: WARNING
                  tags:
                    - tag: trigger
                      value: '{#DB}'
          graph_prototypes:
            - name: 'New graph {#TSNAME} {#DB}'
              graph_items:
                - color: 1A7C11
                  item:
                    host: test
                    key: 'db.ts.size[{#DB}, {#TSNAME}]'
                - sortorder: '1'
                  color: '274482'
                  calc_fnc: ALL
                  item:
                    host: test
                    key: trap
          host_prototypes:
            - host: 'HOST {#DB} {#TSNAME}'
              name: 'HOST {#DB} {#TSNAME}'
              inventory_mode: AUTOMATIC
              group_links:
                - group:
                    name: 'Discovered hosts'
              macros:
                - macro: '{$MACRO}'
                  value: '{{#DB}.btoa()}'
              tags:
                - tag: tag
                  value: '{#DB}'
          parent_discovery_rule:
            key: 1_level_nested_discovery
          lld_macro_paths:
            - lld_macro: '{#TSNAME}'
              path: $.name
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.tablespaces
