Ad Widget

Collapse

Advice on how setup multiple MQTT items using csv file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tim100
    Junior Member
    • Nov 2025
    • 1

    #1

    Advice on how setup multiple MQTT items using csv file

    I’m a Zabbix beginner looking for some guidance on how to "import" several hundred MQTT topics into Zabbix.
    Below is an example of some MQTT topics and returned data. The plan is to create a csv with an item for each topic. The fields will include : MQTT broker, MQTT topic, preprocessing info (eg data type, JSON name)

    N/c061/battery/512/Sense/Voltage {"value":null}
    N/c061/battery/512/System/MinTemperatureCellId {"value":"1 ::1 "}
    N/c061/512/System/MaxTemperatureCellId {"value":"1 ::2 "}
    N/c061/battery/512/Info/MaxChargeVoltage {"value":13.800000190734863}
    N/c061battery/512/System/MinCellVoltage {"value":3.296999931335449}
    N/c062/battery/512/Sense/Voltage {"value":null}
    N/c062/battery/512/System/MinTemperatureCellId {"value":"1 ::1 "}
    N/c062/512/System/MaxTemperatureCellId {"value":"1 ::2 "}
    N/c062/battery/512/Info/MaxChargeVoltage {"value":13.823424}
    N/c062/battery/512/System/MinCellVoltage {"value":3.2934}


    I’m using Zabbix 7.4 (freshly installed this week!) and an agent2 host to access MQTT data. The MQTT data is from Victron equipment.

    What is the simplest and quickest way to get the items into Zabbix, given that I know little about Zabbix at the moment? Looks like writing a python script that uses the Zabbix api is one way to go. Not looking for detailed steps, just a general direction to head down ie is the python script the way to go

    Thanks

  • Viktors Fomics
    Member
    • Oct 2025
    • 42

    #2
    Hello

    It would make sense to create a python script that will read the parameters from the file line by line and will call the item.create method of the Zabbix API (it can be called for each line's parameters separately or for the whole batch). Since there are a lot of items to be added it might be useful to add a duplicate check via item.get API method too.

    Comment

    • Andrejs Poddubņaks
      Junior Member
      • Nov 2025
      • 18

      #3
      Just in addition to what Viktors said.

      There is no native “CSV -> items” import in Zabbix. You’ll need some automation anyway – either via API or by generating a template file.
      Since you’re on 7.4 + agent2 + MQTT, I’d look at it in two layers:
      1. First build one good MQTT item in a template
      Create a template, add one item of type “Zabbix agent (active)” with key like:
      mqtt.get["tcp://your-broker:1883","N/c061/battery/512/Sense/Voltage"]
      2. Add preprocessing: JSONPath → $.value, set correct value type, update interval, etc.​
      3. Link this template to your agent2 host and make sure this one item works.​

      Then mass-create hundreds of similar items
      1. Export your template from the UI (YAML/JSON/XML). https://www.zabbix.com/documentation...port/templates
      2. Write a small Python script that:
      - reads your CSV (broker, topic, JSON path, value type)
      - clones the exported item block for each line,
      - changes only: name, key_ (mqtt.get[…, "topic"]), preprocessing JSONPath if neccessary
      3. Import the generated template back into Zabbix.

      Good luck!​​

      Comment

      Working...