Removing meta data from grafana api response

Hi Team,
Is it possible to remove “meta” data from the api response. Please help me.

  "results": {
    "Inventory": {
      "refId": "Inventory",
      "meta": {
        "executedQueryString": "select .....",
        "rowCount": 121
      },
      "series": null,

I am using curl command to query table output.

Thanks for any help.

Hi @vadiksdba

Can you please tell which API you are calling ?

Thanks

fyi, i don’t want meta in the response.

curl  --request POST 'http://localhost/api/tsdb/query/' \
--header 'Content-Type: application/json' \
--data-raw '{
"queries": [
{
"refId": "test123",
"datasourceId": 777777,
"rawSql": "select some table",
"format": "table"
}
]
}'

Though I am not very expert in the area API’s

But to my best knowledge, it is not possible as this part of information (meta) is coming from the payload.

If you want to remove the meta part, then you need to use some sort of script which can remove this part.

Also, you can try tools like Postman as its a GUI for API’s and might give you some more insights.

Hopefully others might be able to give you here some more information.

Thanks @usman.ahmad, yes, it is possible through script. But i wanted to manage this through REST HTTP call. Not sure, if i need to parse json in nginx :slight_smile:
Thanks,

Why do you want to remove it? and are you talking about this grafana api?

Thanks @yosiasz , i wanted to share one API call(SQL query output) to one of the external user and don’t wanted to include SQL query in that response(just only output).
fyi , I will be handling the API through reverse proxy(request body is included in the reverse proxy)

1 Like

still not clear if this is a grafana api call or some custom api call outside of grafana.

Hi @yosiasz
yes as i mentioned in the above example, i am just query MySQL data source through api.
i guess it looks like in newer versions it is referring to this: Data source HTTP API | Grafana documentation

And how would this external user be using the result of the query result in the grafana context?
never mind! way too late here. I got it now

nope’s, it is not grafana context. we just need to expose query output in json format.

1 Like

short of modifying the source code or writing your own node express api that trims off that data, I don’t thing so.

That’s great!! @yosiasz , but that will effect other things/panels in grafana and more than that, i don’t have much experience to understand programing. Thank you very much!!

It wont affect it because it is a modification of an inline array not changing grafana
Proceed with caution. This is bastardizing grafana api data result. Better off providing what external user needs via some other means.

app.post('/gapi', async (req, res) => {

  const token = "";
  const headers = { "Content-Type": "application/json", 
'Authorization': 'Bearer ' + token};  
                    
  const body = '{"queries": [{"datasourceId": 7,
"rawSql": "SELECT * FROM chrono;"
,"format": "table"}]}'
  try {
    hostsurl = 'http://localhost:3903/api/ds/query/';

    const response = await fetch(hostsurl, {
      method: "post",
      headers: headers,
      body: body,
    });

    
    const data = await response.json();
    
    //bad. try other means like .map
    delete data.results.A.frames[0].schema.meta;    

    return res.json(data);
  } catch (e) {
    throw e.response ? e.response.body.message : e;
  }  
})

Sure @yosiasz , Let me try with what you have suggested.
Thank you very much for all your help’s and support!!.

1 Like

Hi, Were you able to hide the raw sql from Api ? if yes could you please help me out

if you use stored procedures (best practice and performance) then no need to hide it. what previous OP was looking for is an anti-pattern

Good idea. Hope you implemented the same is it possible to share the current output now

what are you trying to accomplish, what are the requirements?

@vadiksdba
Still waiting over 1 year :laughing: