[Infinity] Multiple TimeSeries with one JSON Query (original) (raw)

Hi everyone.

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

image

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]:

image

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:

image

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

image

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:

yosiasz April 29, 2025, 2:55pm 2

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:

image

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.

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

image

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

You may need some JSONata massaging.

Example

   return {
       <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi><mi>e</mi><mi>y</mi><mo>:</mo></mrow><annotation encoding="application/x-tex">key : </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord mathnormal" style="margin-right:0.03588em;">ey</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">:</span></span></span></span>map($lookup($$.panel1, <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>k</mi><mi>e</mi><mi>y</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi>f</mi><mi>u</mi><mi>n</mi><mi>c</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">key), function(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord mathnormal" style="margin-right:0.03588em;">ey</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">u</span><span class="mord mathnormal">n</span><span class="mord mathnormal">c</span><span class="mord mathnormal">t</span><span class="mord mathnormal">i</span><span class="mord mathnormal">o</span><span class="mord mathnormal">n</span><span class="mopen">(</span></span></span></span>v){
        return {
            "key": $key,
            "timestamp": $v[0],
            "value": $v[1]
        }
    })
   }
}).*, function($l,$r){
    <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>l</mi><mi mathvariant="normal">.</mi><mi>t</mi><mi>i</mi><mi>m</mi><mi>e</mi><mi>s</mi><mi>t</mi><mi>a</mi><mi>m</mi><mi>p</mi><mo>&gt;</mo></mrow><annotation encoding="application/x-tex">l.timestamp &gt; </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord">.</span><span class="mord mathnormal">t</span><span class="mord mathnormal">im</span><span class="mord mathnormal">es</span><span class="mord mathnormal">t</span><span class="mord mathnormal">am</span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&gt;</span></span></span></span>r.timestamp
})

image