How to decode data frame from the tsdb API in Grafana 7.5.0

Hello,

I’m trying to create a datasource plugin and trying to integrate tsdb API in the frontend. I’m using Grafana 7.5.X. The response dataframe of tsdb API is encoded. Need help to decode this in frontend which is typescript. Can anyone help related to it.

API response:
{
“results”:{
“A”:{
“refId”:“A”,
“series”:null,
“tables”:null,
“dataframes”:[
“QVJST1cxAAD/////gAEAABAAAAAAAAoADgAMAAsABAAKAAAAFAAAAAAAAAEDAAoADAAAAAgABAAKAAAACAAAAFgAAAACAAAAKAAAAAQAAAAQ////CAAAAAwAAAABAAAAQQAAAAUAAAByZWZJZAAAADD///8IAAAAFAAAAAgAAAByZXNwb25zZQAAAAAEAAAAbmFtZQAAAAACAAAAhAAAAAQAAACW////FAAAADwAAABEAAAAAAAAAkgAAAABAAAABAAAAIT///8IAAAAEAAAAAYAAAB2YWx1ZXMAAAQAAABuYW1lAAAAAAAAAAAIAAwACAAHAAgAAAAAAAABQAAAAAYAAAB2YWx1ZXMAAAAAEgAYABQAAAATAAwAAAAIAAQAEgAAABQAAABEAAAATAAAAAAAAApMAAAAAQAAAAwAAAAIAAwACAAEAAgAAAAIAAAAEAAAAAQAAAB0aW1lAAAAAAQAAABuYW1lAAAAAAAAAAAAAAYACAAGAAYAAAAAAAMABAAAAHRpbWUAAAAAAAAAAP////+4AAAAFAAAAAAAAAAMABYAFAATAAwABAAMAAAAUAAAAAAAAAAUAAAAAAAAAwMACgAYAAwACAAEAAoAAAAUAAAAWAAAAAUAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAoAAAAAAAAACgAAAAAAAAAAAAAAAIAAAAFAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAPgGDjOdwL4W+EZ/lCnHvhb4hrV75+e+FvhGRBpb4b4W+EZEGlvhvhb0AQAAAAAAACwBAAAAAAAAWAIAAAAAAABkAAAAAAAAAMgAAAAAAAAAEAAAAAwAFAASAAwACAAEAAwAAAAQAAAALAAAADgAAAAAAAMAAQAAAJABAAAAAAAAwAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAKAAwAAAAIAAQACgAAAAgAAABYAAAAAgAAACgAAAAEAAAAEP///wgAAAAMAAAAAQAAAEEAAAAFAAAAcmVmSWQAAAAw////CAAAABQAAAAIAAAAcmVzcG9uc2UAAAAABAAAAG5hbWUAAAAAAgAAAIQAAAAEAAAAlv///xQAAAA8AAAARAAAAAAAAAJIAAAAAQAAAAQAAACE////CAAAABAAAAAGAAAAdmFsdWVzAAAEAAAAbmFtZQAAAAAAAAAACAAMAAgABwAIAAAAAAAAAUAAAAAGAAAAdmFsdWVzAAAAABIAGAAUAAAAEwAMAAAACAAEABIAAAAUAAAARAAAAEwAAAAAAAAKTAAAAAEAAAAMAAAACAAMAAgABAAIAAAACAAAABAAAAAEAAAAdGltZQAAAAAEAAAAbmFtZQAAAAAAAAAAAAAGAAgABgAGAAAAAAADAAQAAAB0aW1lAAAAAKgBAABBUlJPVzE=”
]
}
}
}

Tried using apache-arrow - npm but when tried using this getting the below error:

Error: Expected to read 1397380689 metadata bytes, but only read 1472.

Please anyone if there is any solution let me know. Stuck at this point.

Thanks

Could you share an example of what you’d like to use the tsdb API for? For most cases, you shouldn’t need to decode the data frames yourself.

Hey @marcusolsson , I am having a similar issue. The /api/tsdb/query endpoint using the PostgreSQL datasource plugin now returns base64 encoded arrow table responses in Grafana 8.4. In Grafana 7.5 it returns normal table data. I cannot find any mention of how to rectify this breaking change in the docs. Any help is much appreciated.

I have tried to recreate this function however the apache-arrow package has breaking changes since this code was written. I have tried the old versions of apache-arrow without success.

Since /api/tsdb/query is deprecated, I’d encourage you to look at the newer /api/ds/query.

For more information, check out the related issues: