[Infinity] Multiple TimeSeries with one JSON Query

Hi everyone.

I have some issues to create that type of multiple Time Series:

My JSON datas come from an API linked with Infinity and i format them in columns this way. For each column Unix in [0], Value in [1]:

To do that i configured the plugin to parse in FrontEnd, with columnar format, and i have selected the right columns.

After that, i extract the datas and convert them into Time and Number Value:

And i have this result, the values are mixed even if the Unix isn’t the same:

I have tried many things, changing Json format to use dict for each object instead of arrays, other transformations like ‘Prepare Time Series’, but the only solution i found is to make multiple Queries, one for each Curve. But for my application, i need to make a single Query.

Do you have a solution ?

Thank you :slight_smile:

hello @gerryjouaud

please provide a sample json data?

For sure, here it is :

{
  "panel1": {
    "current shift": [
      [
        1745884821000,
        0
      ],
      [
        1745885172000,
        0
      ],
      [
        1745885172000,
        1
      ]
	],

    "shift - 1": [
      [
        1745884821000,
        0
      ],
      [
        1745884824000,
        0
      ],
      [
        1745884824000,
        1
      ],
      [
        1745884824000,
        2
      ],
      [
        1745884824000,
        3
      ],
      [
        1745885619000,
        4
      ],
      [
        1745885619000,
        5
      ]
    ],
    "shift - 2": [
      [
        1745884821000,
        0
      ],
      [
        1745885029000,
        0
      ],
      [
        1745885029000,
        1
      ],
      [
        1745885029000,
        2
      ],
      [
        1745885029000,
        3
      ],
      [
        1745885072000,
        4
      ],
      [
        1745885072000,
        5
      ]
    ]
  }
}

Thank you for helping !

Edit:

  • I specify the root here:

And it doesn’t work when i try to access columns with something like that: ‘current shift.*.0’ to specify to grafana current shift time field for example.

  • I think the error come from the multiple extract fields, but do i have another solution ?

  • I realized with that little sample that the number of rows is determined by the first column ‘current shift’ here. So even others columns have 3 rows even if they have more row objects.

  • Must i format my Json in a different way and have for each object : [‘unix’,value1,value2,value3’] ?

Format JSON this way make the panel creation much easier, with only one understandable time stamp value for Grafana: [time_stamp,value1,value2,value3]

But just for my Grafana knowledge; was it possible with my previous format ?

You may need some JSONata massaging.

Example

$sort($map($keys($.panel1), function($key) {
   return {
       $key : $map($lookup($$.panel1, $key), function($v){
        return {
            "key": $key,
            "timestamp": $v[0],
            "value": $v[1]
        }
    })
   }
}).*, function($l,$r){
    $l.timestamp > $r.timestamp
})

2 Likes