Using Grafana version 11.2.2
I am trying to use a UQL query to modify my JSON data returned by an API query. I am using a UQL query as follows.
parse-json
| jsonata $map(content.rows,function($row){$map($row,function($cell,$index){$index = 2 and $cell[0] = "BE4" ? ["EMEA"] : $cell})})
Against the following JSON
{
"content": {
"columns": [
"Device",
"IP Address",
"Instance"
],
"rows": [
[
[
"condarsbe08.acme.com"
],
[
"10.10.210.213"
],
[
"BE4"
]
],
[
[
"condarsbe15.acme.com"
],
[
"10.10.210.220"
],
[
"BE3"
]
],
[
[
"condarsbe04.acme.com"
],
[
"10.10.210.209"
],
[
"BE4"
]
],
[
[
"condarsbe13.acme.com"
],
[
"10.10.210.218"
],
[
"BE3"
]
],
[
[
"condarsbe06.acme.com"
],
[
"10.10.210.196"
],
[
"BE4"
]
],
[
[
"condarsbe02.acme.com"
],
[
"10.10.210.207"
],
[
"BE1"
]
],
[
[
"condarsbe03.acme.com"
],
[
"10.10.210.208"
],
[
"BE2"
]
],
[
[
"condarsbe06.acme.com"
],
[
"10.10.210.196"
],
[
"BE1"
]
],
[
[
"condarsbe08.acme.com"
],
[
"10.10.210.213"
],
[
"10.10.210.220"
],
[
"BE1"
]
],
[
[
"condarsbe11.acme.com"
],
[
"10.10.210.216"
],
[
"BE4"
]
],
[
[
"condarsbe08.acme.com"
],
[
"10.10.210.213"
],
[
"BE2"
]
]
]
},
"id": "0-t62ce-6937c556",
"name": "Backends",
"path": "All/Report Library/System Health/Inventory/Backends",
"properties": {},
"time-range": {
"end": 1743014107,
"start": 1742927707
},
"type": "table"
}
The query has been tested in JSONata exerciser and works as expected. See screen shot highlighted in yellow, the text was originally BE4 and have been changed to “EMEA”, as required
The end result is to have all of the Instance values, BE1, BE2, BE3, BE4, updated to read as EMEA. Im only testing for BE4 in this example.
However when I run this as a UQL query it comes back with the errors saying ‘error applying uql query’. I think this is a syntax issue but im lost and need help. I am creating this data source as a mixed data source as I need to call multiple sources and join the results together. In this example I am only getting the data from one API call.