Ad Widget

Collapse

Setting up MQTT monitoring with Zabbix 6.0(LTS), agent2, mosquitto and zigbee2mqtt

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cgrenier
    Junior Member
    • Nov 2025
    • 3

    #1

    Setting up MQTT monitoring with Zabbix 6.0(LTS), agent2, mosquitto and zigbee2mqtt

    Hello
    On a Raspberry pi, zigbee2mqtt is sending the results to a local mosquitto instance and zabbix-agent 2 is running with active checks enabled.
    On the zabbix server interface, a master item has been created for the Raspberry pi:
    - name: zigbee-cgr
    - type: Zabbix agent (active)
    - key: mqtt.get["","zigbee2mqtt/zigbee-cgr/#"]
    - no preprocessing
    When I asked for previous values, I can results like
    2025-11-17 16:41:58 {"zigbee2mqtt/zigbee-cgr":"{"humidity":48.95,"linkquality":224,"t e mperature":22.17}"}

    A dependant item has been created:
    - name: Temperature [C]
    - type: Dependant Item
    - Key: temperature
    - Type of information float
    - Master item: zigbee-cgr
    - Preprocessing: JSONPath $.temperature

    Preprocessing failed for: {"zigbee2mqtt/zigbee-cgr":"{"humidity":49.39,"linkquality":232,"t e mperature":21.93}"}
    1. Failed: cannot extract value from json by path "$.temperature": no data matches the specified path

    I have found another post about MQTT but it wasn't using mosqutto. I also read Ivo_Schooneman_Feeding_Zabbix_with_MQTT_data.pdf without understanding what was broken in my setup.
    What should I do to fix it ?
  • Answer selected by cgrenier at 02-12-2025, 17:17.
    cgrenier
    Junior Member
    • Nov 2025
    • 3

    Thanks for your help. I have been able to solve it by adding a PreProcessing in the master item.

    On the zabbix server interface, a master item for the Raspberry pi is now
    - name: zigbee-cgr
    - type: Zabbix agent (active)
    - key: mqtt.get["","zigbee2mqtt/zigbee-cgr/#"]
    - JSONPath Preprocessing $['zigbee2mqtt/zigbee-cgr']

    The dependant item is unchanged:
    - name: Temperature [C]
    - type: Dependant Item
    - Key: temperature
    - Type of information float
    - Master item: zigbee-cgr
    - Preprocessing: JSONPath $.temperature

    Comment

    • BP_Vital
      Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Feb 2016
      • 42

      #2
      Preprocessing failed for: {"zigbee2mqtt/zigbee-cgr":"{"humidity":49.39,"linkquality":232,"t e mperature":21.93}"}
      cannot extract value from json by path "$.temperature"

      I'd say fixing template would be faster to include those extra spaces if they appear everywhere,
      OR additional custom preprocessing step to convert "t e mperature" -> "temperature" is a shortcut too.

      Comment

      • cgrenier
        Junior Member
        • Nov 2025
        • 3

        #3
        Click image for larger version

Name:	image.png
Views:	58
Size:	20.8 KB
ID:	508957

        Click image for larger version

Name:	image.png
Views:	54
Size:	26.8 KB
ID:	508958
        Thanks for your reply but the extra spaces only appears in my post on the zabbix forum when I choose "Preview" in the forum (maybe to wrap long line).
        Another idea ?

        Comment

        • BP_Vital
          Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Feb 2016
          • 42

          #4
          I'm confused by slash symbols in the master item JSON. Maybe try to preprocess string getting rid of them?
          Also i suspect $.temperature is not sufficient in that case, you probably need to go deeper into JSON to extract that temperature value.
          I usually debug Jsonpath by testing preprocessing with those <IMAGE>
          Try to paste raw value you would get from agent and preprocess with different Jsonpath.
          Attached Files
          Last edited by BP_Vital; 19-11-2025, 11:13.

          Comment

          • cgrenier
            Junior Member
            • Nov 2025
            • 3

            #5
            Thanks for your help. I have been able to solve it by adding a PreProcessing in the master item.

            On the zabbix server interface, a master item for the Raspberry pi is now
            - name: zigbee-cgr
            - type: Zabbix agent (active)
            - key: mqtt.get["","zigbee2mqtt/zigbee-cgr/#"]
            - JSONPath Preprocessing $['zigbee2mqtt/zigbee-cgr']

            The dependant item is unchanged:
            - name: Temperature [C]
            - type: Dependant Item
            - Key: temperature
            - Type of information float
            - Master item: zigbee-cgr
            - Preprocessing: JSONPath $.temperature

            Comment

            Working...