How To get a column per field count

Hi,

I have some elasticsearch data I am trying to present in Grafana, here’s an abridged example of some docs:

{
“_id”:1,
“name”: “foo”,
“location”:“hastings”}
{
“_id”:2,
“name”: “foo”,
“location”:“brighton”
}
{
“_id”:3,
“name”: “foo”,
“location”:“eastbourne”
}
{
“_id”:4,
“name”: “foo”,
“location”:“brighton”
}

What I’d like to see in Grafana is a table panel something like:

|  name  |  hastings  |  brighton  |  eastbourne |
|  foo   |     1      |     2      |       1     |

Any idea on how to write a query like this, I am really struggling!

There’s no easy way of writing such a query in Grafana I’m afraid.