Group by Date with JSON api

Hi,
I am using grafana through the JSON API plugin, and I would like to know if it was possible to group the values by day, that is, the API output is minute-by-minute records, and I would like to know if it was possible to make sums/averages of these values and group them by day.

For example:
Suppose this output comes from the API:

[
    {"date":"2022-03-03 09:00:00","value":100},
    {"date":"2022-03-03 09:01:00","value":120},
    {"date":"2022-03-03 09:02:00","value":115},
    {"date":"2022-03-04 09:00:00","value":129},
    {"date":"2022-03-04 09:01:00","value":101},
    {"date":"2022-03-04 09:02:00","value":108}
]

The result I wanted was for example this:

[
    {"date":"2022-03-03","value":345},
    {"date":"2022-03-04","value":338},
]

Is this possible to do in grafana, considering this api output?

Thank you

Yes, you can extract the dates in one column using a JSONata query, splitting at the space and then grabbing the first index. Something like:

$map($, function($v) {(
    ($split($v.date, " ")[0]);
)})

Then using transformations you can select the “Group by” transformation. Group by date and calulate value. Select the total operation and you should get your desired output.

1 Like

Thank you very much @ollisco. It worked