Table showing only the last line of JSON collect

  • What Grafana version and what operating system are you using?
    Grafana v9.5.2 on Ubuntu

  • What are you trying to achieve?
    I have a Zabbix that collects a metric in CSV and convert it to JSON, this is working fine. I want to reproduce this visualization on Grafana on the Table panel, so each JSON object has to be in different line, one below another.

  • How are you trying to achieve it?
    I created a dashboard, added my zabbix query and selected the Table panel. Then, I use “Transform” on panel and added “Extract Fields”, selected my metric name and put Format as “Key+value+pairs” and enable option “Replace All Fields”.

  • What happened?
    it shows me only the last line of the JSON response, instead of 8 lines.

My JSON is:
[{
“JOB_NAME”: “B”,
“LOG_DATE”: “2023-08-09 01:17:51”,
“OPERATION”: “RUN”,
“STATUS”: “FAILED”
}, {
“X”: “A”,
“DATE”: “2023-07-13 03:59:14”,
“OPERATION”: “RUN”,
“STATUS”: “FAILED”
}, {
“X”: “B”,
“DATE”: “2023-07-13 01:28:14”,
“OPERATION”: “RUN”,
“STATUS”: “FAILED”
}, {
“X”: “A”,
“DATE”: “2023-07-12 04:01:31”,
“OPERATION”: “RUN”,
“STATUS”: “FAILED”
}, {
“X”: “B”,
“DATE”: “2023-07-12 01:22:02”,
“OPERATION”: “RUN”,
“STATUS”: “FAILED”
}, {
“X”: “A”,
“DATE”: “2023-07-11 01:49:28”,
“OPERATION”: “RUN”,
“STATUS”: “FAILED”
}, {
“X”: “B”,
“DATE”: “2023-07-10 22:26:17”,
“OPERATION”: “RUN”,
“STATUS”: “FAILED”
}, {
“X”: “A”,
“DATE”: “2023-07-10 01:40:24”,
“OPERATION”: “RUN”,
“STATUS”: “SUCCEEDED”
}]

Zabbix execute this only once a day and Grafana dashboard time range panel is 1 day, Table panel is showing only the LAST line of JSON, so now I have a panel with just one line, instead of the 8 lines of the JSON. My Grafana table is showing:
X": “A” | “DATE”: “2023-07-10 01:40:24” | “OPERATION”: “RUN” | “STATUS”: “SUCCEEDED”

Why it’s retrieving just the last line of JSON response? On Zabbix, everything is OK and I have my entire JSON.

I’m having the same issue. Did you solve it?

I made a workaround to this issue… It works very well, but requires a few steps:
First, I made a basic python script that uses Zabbix API. This is script basically connects to the API, then I pass the itemid and hostid of them item that it’s collecting this CSV response, and then I treat this to output the response on a txt file separated by “;” (when this item rssponse on zabbix is already formatted, you don’t need to do it) and add a header. Then, this script will create this txt file which contains just the CSV value of the zabbix item.
I made it execute via cron, so it update when you need to.
This script was made on grafana host, so then I used the CSV datasource and just reference this txt file path on “Path” tab and set the other configs on panel.
It’s not the best way to do it, but it’s working for me

what does zabbix api result look like?

The reason is because there are multiple values for X in the array, so it only returns the last value.

1 Like

It output the value of the zabbix item id that you pointed on code, when you call zabbix api, something like:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "itemid": "90410",
            "lastvalue": <zabbix-item-response-here>
}
    ],
    "id": 1
}

That’s why I had to treat the response on the script, to get only “lastvalue” value and organize data

Thanks for your response!

In my case, I was just testing grafana on top of zabbix. So, I dropped grafana for the moment.
My solution is to use an html table instead of a json object as the value of my zabbix item, and show it directly in the zabbix dashboard.