Json key:value pair in data

Grafana 9.3,2 on MacOS 12.6.2 (Monterey)

I’m trying to import and chart some device statistics from the device’s Rest API. The statistics will be in the form of one or more metrics covering a 30 minute period, and the star and end times of the 30 minute period

The JSON received looks like this (this is 3 periods worth. 0, 1 & 10)

{‘data’: {
‘0’: {‘data’: {‘0’: 0},
‘end_time’: ‘2023-01-14 00:30’,
‘start_time’: ‘2023-01-14 00:00’},
‘1’: {‘data’: {‘0’: 0},
‘end_time’: ‘2023-01-14 01:00’,
‘start_time’: ‘2023-01-14 00:30’},
‘10’: {‘data’: {‘0’: 0},

Using the Infinity data source and a UQL query I can successfully import the data into a table.

UQL query is this:

parse-json
scope “data”
jsonata “[*]”

What I get back is this:

This is what I would expect, but what I can’t work out is how to now extract the value from the key:value pair in the data column while at the same time keeping the end_time values

If I modify my UQL query thus:

parse-json
scope “data”
jsonata “[*.data]”

then I get the values I want, but I lose the start_time and end_time columns, which I need to create a time based chart,

Any and all hints very gratefully received

Check oit the extract fuelds feature in Tranformayion tab

Yep, that’s what I was after. Thank you

1 Like