Ad Widget

Collapse

Which SNMP Walk preprocessing is faster, Regex or JSONPath

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markfree
    Senior Member
    • Apr 2019
    • 868

    #1

    Which SNMP Walk preprocessing is faster, Regex or JSONPath

    I have some devices that discover many items each.
    I'm refactoring their template so that the devices can benefit from the SNMP Walk feature.

    The parent "Walk" item finds many SNMP OIDs and its dependent items use preprocessing to identify the item values.

    As I see it, Regex should work fine for each dependent item.
    However, if I map the SNMP walk parent item to JSON, I could benefit from the JSONPath preprocessing.

    So my question is, which preprocessing do you guys think
    would be best:
    • Main item with no preprocessing and simple regex for each dependent item?
    • Or, main item with "SNMP walk to JSON" preprocessing, and JSONPath preprocessing for each dependent item?

    PS: I'm thinking of thousands of items.
    Last edited by markfree; 08-06-2024, 17:38.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Regex will go over whole "file" line by line (until match). Jsonpath walks the path... Thus I would say jsonpath is faster...

    Comment

    • markfree
      Senior Member
      • Apr 2019
      • 868

      #3
      I guess so...
      Is there a way to measure each one?

      I'll try to debug these preprocessing steps.

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #4
        I have no idea, how to benchmark it...

        Comment

        • aigars.kadikis
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Mar 2018
          • 208

          #5
          Starting with 7.0.17, 7.4.1 there is a runtime command to ask about which itemid bursts the preprocessing:
          zabbix_proxy -R diaginfo=preprocessing



          I think to make benchmarking who will win JSONPath VS regEx, we can create a master item "HTTP agent", "Zabbix trapper", "Script" (and hardcode input) and 2 dependent items.
          Set the 3 items to be only items on a single proxy.

          Here is minimal (active) proxy config (can run in parallel of existing proxy)
          Code:
          echo "
          DBName=/tmp/min_zabbix_proxy.sqlite3
          Hostname=minimal
          LogType=console
          PidFile=/tmp/minimal_zabbix_proxy.pid
          Server=aigars.zabbix.cloud
          StartAgentPollers=0
          StartBrowserPollers=0
          StartDBSyncers=1
          StartDiscoverers=0
          StartHTTPAgentPollers=0
          StartHTTPPollers=0
          StartODBCPollers=0
          StartPingers=0
          StartPollers=1
          StartPollersUnreachable=1
          StartPreprocessors=1
          StartSNMPPollers=0
          StartTrappers=0
          " | sudo tee /root/minimal_zabbix_proxy.conf
          to run in foreground:
          Code:
          zabbix_proxy -c /root/minimal_zabbix_proxy.conf -f
          In another terminal see stats of itemIDs
          Code:
          zabbix_proxy -c /root/minimal_zabbix_proxy.conf -R diaginfo=preprocessing
          I tried to benchmark myself with this Proof of Concept host (not template):
          Code:
          {
              "zabbix_export": {
                  "version": "7.0",
                  "host_groups": [
                      {
                          "uuid": "e34c64a05273412ba868d8b04b812089",
                          "name": "tempo"
                      }
                  ],
                  "hosts": [
                      {
                          "host": "regEx VS JSONPath",
                          "name": "regEx VS JSONPath",
                          "monitored_by": "PROXY",
                          "proxy": {
                              "name": "minimal"
                          },
                          "groups": [
                              {
                                  "name": "tempo"
                              }
                          ],
                          "items": [
                              {
                                  "name": "input",
                                  "type": "SCRIPT",
                                  "key": "input",
                                  "delay": "1s",
                                  "value_type": "LOG",
                                  "trends": "0",
                                  "params": "return '[{\"name\":\"hello\",\"surname\":\"world\"}]';",
                                  "timeout": "1s"
                              },
                              {
                                  "name": "jsonpath",
                                  "type": "DEPENDENT",
                                  "key": "jsonpath",
                                  "delay": "0",
                                  "value_type": "LOG",
                                  "trends": "0",
                                  "preprocessing": [
                                      {
                                          "type": "JSONPATH",
                                          "parameters": [
                                              "$[0].name"
                                          ]
                                      }
                                  ],
                                  "master_item": {
                                      "key": "input"
                                  }
                              },
                              {
                                  "name": "regex",
                                  "type": "DEPENDENT",
                                  "key": "regex",
                                  "delay": "0",
                                  "value_type": "LOG",
                                  "trends": "0",
                                  "preprocessing": [
                                      {
                                          "type": "REGEX",
                                          "parameters": [
                                              "name...([^\"]+)",
                                              "\\1"
                                          ]
                                      }
                                  ],
                                  "master_item": {
                                      "key": "input"
                                  }
                              }
                          ],
                          "inventory_mode": "AUTOMATIC"
                      }
                  ]
              }
          }
          After waiting 3m and executing master item every 1s, the RegEx itemid appiered in list which makes JSONPath the winner.
          Last edited by aigars.kadikis; 09-12-2025, 11:37.

          Comment

          Working...