Ad Widget

Collapse

Trying to convert JSON data to a table with rows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rjpiston
    Junior Member
    • Jul 2024
    • 1

    #1

    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:

    HTML Code:
    [
      {
        "app": "app_name_1",
        "status": "online"
      },
      {
        "app": "app_name_2",
        "status": "stopped"
      }
    ]
    I'm using the following query:


    HTML Code:
     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 either create a table in Zabbix or Grafana. 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 what but i'm stuck.


Working...