Trying to convert JSON data to a table with rows

I’m using Zabbix 7.0 with grafana. I’m trying to get a list of pm2 instances into a simple table with App Name, and Status headers.

I’ve created a bash script that grabs the output of pm2 jlist and grabs the name and status fields and then echo’s the new json output to zabbix using a UserParameter in a conf file.

I’ve created the item in Zabbix and the JSON is being returned succesfully as follows:

[
  {
    "app": "app_name_1",
    "status": "online"
  },
  {
    "app": "app_name_2",
    "status": "stopped"
  }
]

I’m using the following query:

SELECT  
    clock AS time,  
    value   
FROM   history_text  
WHERE   itemid IN (SELECT itemid FROM items WHERE key_ = 'custom.pm2.app.names')  
ORDER BY   time 
DESC  LIMIT 1

I’m looking to create a table. I tried using the transformations in Grafana but I can’t get it to display as rows, it just extracts the data into more columns. I’m not sure if I should change the json structure or im using the transformations wrong, what but i’m stuck.

Infinity plugin parses such JSON without any transformations:

As for Zabbix datasource, see this topic:

1 Like

Thank you I will give your solution a try!